I have a UISplitViewController but my delegate class doesn't ever get the -prepareForSegue:sender message. I've confirmed this is the case because I subclassed UISplitViewController and it's was preparing for every freaking segue it was orchestrating.
Is there any better way to get around this, save for subclassing UISplitViewController just to forward one message...?
Related
I've been looking through some very helpful examples on how implement custom transitions between segues (e.g this one).
But I just can't figure out how to do this with UISplitViewController.
Can I get any hint/tips?
I know that in the MasterViewController you can prepareForSegue when showing a new DetailedViewController. But setting the transitioningDelegate on the destinationViewController does not seem to work at all.
I also tried to set the MasterViewControlleras the NavigationViewControllerDelegate and return the UIViewControllerAnimatedTransitioning, but that didn't work either (as expected, but I wanted to try).
On iOS 7.x (only), When I call [self performSegueWithIdentifier:#"MySegue"], while self is a UINavigationController, I get the following NSGenericException:
Could not find a navigation controller for segue 'MySegue'. Push
segues can only be used when the source controller is managed by an
instance of UINavigationController.
Oddly enough, on iOS 8.x it works perfectly!
Every solution I saw regarding this exception tells you to embed the source view controller inside a UINavigationController, however in my case self is already a UINavigationController by itself.
It makes sense that performSegueWithIdentifier: would work when called on UINavigationController, and it does on iOS 8, so what's the problem on iOS 7??
Very first reaction - How did you manage to create a segue from a UINavigationController??? In Storyboard you can create a relationship from UINavigationController, not a segue!
Well, I am amazed if it is working on iOS 8. But conceptually you cannot ask UINavigationController to performSegueWithIdentifier as a segue with push is just a graphical way of asking the sourceViewController to push segue's destinationViewController.
In this case, how are you trying to tell a UINavigationController to perform a segue? It does not have a navigationController, it itself is!!!
So I guess if it works on iOS 7 its a bug there.
What you should be doing :
Either perform the selector -performSegueWithIdentifier on the controller which is the source of the segue.
OR
Ask the UINavigationController to push your destinationViewController.
in my iPad-app I connected a UIButton to another UIViewcontroller by just dragging in Storyboard and chose popover as segue. Everything is working fine, but the user can dismiss the popover by touching just somewhere besides the popover right.
How can I detect that the popover has dismissed in iOS8? In iOS7 I could just use the UIPopoverDelegate -popoverDidDidmiss...
But this is not working anymore!? I googled a lot but could not find any solution.
You put your
-(void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController
in the UIViewController where the start UIButton is ? (not in another popover UIViewcontroller ?)
That work well for me with iOS 8.1...
You have to delegate to the initial UIViewController for that.
I assume you set the delegate properly, but do you retain the popover, i.e. assign it to a strong property? In ios7 if you didn't retain the popover you would get exception: '[UIPopoverController dealloc] reached while popover is still visible.' In ios8 this is not longer the case, so you get the working popover and you can dismiss it, but the delegate methods are not called anymore.
(Frankly speaking, I'm not sure why this is so. I'd suppose that at least "should dismiss popover" should be called anyway).
You should probably use UIPopoverControllerDelegate and the method
popoverControllerDidDismissPopover:
to accomplish what you need.
in iOS8, it is using the UIViewController's UIPopoverPresentationController to present the popover. (Optionally you still can use back the old UIPopoverController to build the popover manually.
If you are using storyboard on iOS8, you can set the UIViewController's popoverPresentationController delegate to handle the followings:
popoverPresentationControllerShouldDismissPopover:
popoverPresentationControllerDidDismissPopover:
I'm working on an iPhone app where I move through push through several view controllers. On the last on I [self.navigationController popToRootViewControllerAnimated:YES]
I want to ask is there a way to detect that I just came from ViewController7 when i return to the ViewController1?
The reason being i'd like the viewDidAppear to behave in a certain way if it is.
Otherwise is it possible to rerun the ViewDidLoad? (I'm presuming its not).
Thanks.
You could have your viewController1 conform to the UINavigationControllerDelegate protocol and become the UINavigationController's delegate. Then in navigationController:willShowViewController:animated: check if the controller to be shown is viewController1, check your UINavigationController's visibleViewController and set some variable in viewController1. Then in viewDidAppear you can animate appropriately.
I'd use the delegation design pattern to set a protocol method to send information back regarding what view controller you are in.
I am trying to set up a UISplitViewController in a Storyboard with the detail going to a UITabBarController which then goes to a UINavigationController wrapping my first ViewController.
The problem I am having is getting the UIBarButtonItem to show up in the Navigation Item when the device is in the portrait orientation. Should the UITabBarController be the delegate for the UISplitViewController and send delegate message to every child view controller to have them create the bar button item and popover?
I found need for this same solution. I am using it in one of my prototype applications for home-control.
The problem you cite is only the first of a couple of problems you'll run into. I believe i have full the solution now working for both iPad/iPhone (Universal app).
You can read my post here: problem and solution description with sample code at my blog
In summary, you'll run into the following issues (most for iPad imple., some for iPhone imple. when building Universal app.):
The template code in appDelegate sets up delegate incorrectly for the new shape (it really no-longer understands what type of controller is present for the detail view
UISplitViewController delegate calls are not propagated thru the UITabbarController to the tabs correctly
You will need to decide how/when to notify the tab(s) of the current detail selection
When building as Universal App some of the notification now need to happen in prepareForSegue: methods (as some of the other notifications don't happen on the iPhone platform.)
(All of this is shown at my blog post)
You can find example and theory in this site. Very good example.