Warning: Attempt to Present Modaltableviewcontroller on Maintableviewcontroller Which Is Already Presenting (Null)

Warning: Attempt to present ModalTableViewController on MainTableViewController which is already presenting (null)

I'm not on swift yet, but for Objective-C, I ended up wrapping the presentViewController call in a performSelector call.

-(void) present
{
[self performSelector: @selector(ShowModalTableViewController) withObject: nil afterDelay: 0];
}

-(void) ShowModalTableViewController
{
[self presentViewController: ctrlModalTableViewController animated: true completion: nil];
}

Attempt to present ViewController which is already presenting (null)

So I tried a lot of messing about with the dispatch_async and dispatch_sync methods and each time, no matter what I did I was getting a lock condition that froze the UI.

Upon further inspection of the documentation (and my code), I provided the block instead to the AlertControllerAction instead of the presentViewController. Thanks to this post for providing the syntax. The resulting changes are as follows:

// MARK: Alert Related Methods
func showAlert(text : NSString, title : NSString, fn:()->Void){
var alert = UIAlertController(title: title, message: text, preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: {(alert: UIAlertAction!) in fn()}))
UIApplication.sharedApplication().delegate?.window!?.rootViewController?.presentViewController(alert, animated: true, completion: nil)
}

And then went about calling it like so:

private func showAccountCreatedAlertThenLoadMainStoryboard(){
self.showAlert("You will now be logged in", title: "Account created", fn: {self.switchToMainStoryboard()})
}

The required sequence is now happening without issue. Hope this helps someone else.

SwiftUI [Presentation] / Attempt to present View on ... which is already presenting

Your .sheet(isPresented: $showingOtherView) { is inside the ForEach. When you set showingOtherView to true, all the sheets in the ForEach will try to present. That's a looooot of sheets.

You want to put it outside the ForEach.

var body: some View {
List {
ForEach(self.localList) {
item in
HStack {
Spacer()
Button(action: {
self.handleCustomItem(item)
})
{
Text(item.expression!)
.foregroundColor(Color.red))
.font(.headline)
.padding(.horizontal, 11).padding(.vertical, 15)
}
Spacer()
}
}
}
.sheet(isPresented: $showingOtherView) { /// here should be fine
OtherView()
}
}

Breakpoint for Warning: Attempt to present * on * which is already presenting *

First things first, you need to set a symbolic breakpoint to -[UIViewController presentViewController:animated:completion:]. You can add this easily via Xcode's Add Symbolic Breakpoint feature.

Secondly, you need to set a condition so that the breakpoint is hit only when the view controller already presents something. Programatically speaking, this means that the presentedViewController property is non-nil. The trick here is to access the self implicit parameter passed to any method call, which can be done by using $arg1 (more details on that here). Once you have this, the rest is easy.

Here's how the breakpoint should look like:

Breakpoint

(source: cristik-test.info)

In summary:

Symbol: -[UIViewController presentViewController:animated:completion:]

Condition: [(UIViewController *)$arg1 presentedViewController] != nil

This works for Objective-C as well as Swift projects, since the UIViewController is (still) exporting its public methods as Objective-C symbols.

iOS 8 multiple popovers - Warning: Attempt to present * on * which is already presenting (null)

Adding

self.navigationController?.popoverPresentationController?.passthroughViews = nil

in the containing viewcontroller in the popover at least fixed so when clicking another button in the navigationitem did trigger a dismiss of the other popover.



Related Topics



Leave a reply



Submit