I am facing a little issue inside my project. I have a simple IPad app that is using SplitView in Lanscape orientation. MasterViewController is a tableview while DetailView is the WebView as shown below:
The above diagram results in the following:
After that, i have put the whole thing inside ECSlidingViewController. Tapping on the "Menu" button in MasterViewController will reveal the side menu as shown below:
Now i can tap on some other option in the menu, let us say i have tapped "Contact" inside the Menu, the associated view controller will come up as shown below: (This view controller does not have any detailview)
Everything till this point is fine and exactly what i wanted!!!! The problem starts now when i tap the Menu button again to reveal the menu and select the "Navigation" again to reveal the tableview. When the "Navigation" is tapped, it shows the MasterView but hides the DetailView as shown below:
Other than that, tapping on any entry in the tableivew above will cause the program to crash with the following message in console:
* Assertion failure in -[UIStoryboardReplaceSegue perform], /SourceCache/UIKit_Sim/UIKit-2380.17/UIStoryboardBuiltInSegues.m:63
2013-03-30 13:59:58.179 19IPadIPad[5806:c07] * Terminating app due
to uncaught exception 'NSInternalInconsistencyException', reason:
'Could not find a split view controller ancestor for
'', while performing a split view
controller replace segue (identifier 'pushLink') with destination
'''
*** First throw call stack: (0x217b012 0x16bce7e 0x217ae78 0x1152665 0xa57349 0xa48b99 0xa48c14 0x6b0249 0x6b04ed 0x10ba5b3 0x213a376
0x2139e06 0x2121a82 0x2120f44 0x2120e1b 0x1d587e3 0x1d58668 0x600ffc
0x24bd 0x23e5) libc++abi.dylib: terminate called throwing an exception
Can somebody look into the problem and tell where the problem could be. Thanks in advance.
UPDATE:
After talking to the user on chat who suggested that after i tap the navigation in menu, the next thing that appears is only the masterview and splitview is actually not loaded. Looks like that is the problem but i don't know how to fix that.
UPDATE:
How ECSlidingView Is Integrated With The SplitView
I am updating the question after receiving a comment asking how the ECSlidingView is connected to the project and the SplitView.
I have created a class named 'MainSplitViewController' inherited from UISplitViewController, and connected it with the splitView in my storyboard in the identity inspector. Also i have given it the Storyboard ID of "SplitTop".
Then in my InitialViewController i have called the SplitView as the topviewcontroller as follow:
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
self.topViewController = [storyboard instantiateViewControllerWithIdentifier:#"SplitTop"];
}
The ECSlidingView menu appears when the "Menu" button is pressed on the MasterViewController as you can see in the images above. That menu button is using an IBAction to reveal the ECSlidingView:
- (IBAction)revealMenu:(id)sender {
[self.slidingViewController anchorTopViewTo:ECRight];
}
I have also used ECSlidingViewController in a test project i was working on. I guess i am able to understan the problem you are having.
First of all this problem does not have anything to do with SplitView or your navigation controller inside it as you can remove SplitView and it will work fine. This problem is associated completely how you are integrating SplitViewController inside the ECSlidingView library.
After going through the images you have posted above, it seems like ECSlidingViewController was added to the project before you started working on the SplitView. That means in your code, the navigation menu is still connected to your MasterViewController. It should be connected to the SplitViewController.
As your updated question suggests that you are calling your SplitView in the InitialView as follow:
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
self.topViewController = [storyboard instantiateViewControllerWithIdentifier:#"SplitTop"];
}
But the above code is just setting it to be the TopViewController. I have checked the ECSlidingView library and you will notice that the Menu table view that gets revealed is handled by the MenuViewController. That means you have to make necessary changes inside this class.
As your StoryBoard ID for MainSplitViewController class is set as 'SplitTop', you can add it in the ViewDidLoad section of the MenuViewController class where the whole array is defined that is drawing the Menu items.
Hope that helps.
Related
I've got a segue that opens a viewcontroller via a storyboard reference in the viewDidLoad of the parent controller. Everything worked in the earlier versions of iOS and Xcode, however it seems to give me a crash now with the message
[Assert] Assuming bar button item's view exists.
I'm not sure what to do - I've tracked the crash down to the line which references the segue that opens the referenced viewcontroller.
I've set the anchor as the bar button item.
[self performSegueWithIdentifier:#"menuPopSegue" sender:nil];
Make sure you have set the identifier in storyboard which you are calling here.
I moved my code into the viewDidAppear method instead of the viewDidLoad (where it originally was). It now works and presents the viewController in a popOver - I assume the problem was because in the viewDidLoad items were initialised but not actually presented yet on screen and the new UIPopoverPresentationController class requires the anchor and its properties to be fully loaded.
I'm currently trying to use push segue to navigate between two views. This works fine elsewhere in my app, no problems. However, in this particular location, I'm presented with the following error:
Terminating app due to uncaught exception 'NSGenericException',
reason: 'Push segues can only be used when the source controller is
managed by an instance of UINavigationController.
Now here's the thing, i know exactly what this error means, and exactly how to fix it.
Editor -> Embed in -> Navigation Controller on the view controller i'm trying to push from.
The thing is, I've done that already and the error persists. Any ideas?
For what it's worth, the navigation bar doesn't even appear in the view that was embedded inside the nav controller.
Here is the current setup
I have a ViewController on the storyboard that is setup to inherit from UIViewController. That controller is embedded inside a UINavigation controller via the above method.
On this view controller view, there are two buttons. Inside IB I have dragged a push segue from each of those buttons to the respective view controllers I would like to present.
I've also tried doing the segue in code via the following:
- (IBAction)btnTerms:(id)sender {
UIViewController *termsVC = [STORYBOARD instantiateViewControllerWithIdentifier:#"TermsOfServicesViewController"];
[self.navigationController pushViewController:termsVC animated:YES];
}
In the above case, nothing happens at all. No crashes or anything. Debugger breakpoints confirm that the method is being hit, though.
Update as per Phillip's question
UINavigationController *nav = self.navigationController;
[self.navigationController pushViewController:termsVC animated:YES];
- (IBAction) btnSignUpCLicked:(UIButton *)sender {
[self presentViewController:[STORYBOARD instantiateViewControllerWithIdentifier:#"SignUpViewController"] animated:YES completion:nil];
}
From the comments:
Embedding a view controller inside a navigation controller will cause the embedded controller to load when its navigation controller does. The reverse is not implied (, which is reasonable because there might be a case where the embedded controller would be also useful standalone).
So I have a programmatically created array of "buttons" which are actually UIImageViews. All of the buttons can create an action, or give an Alert. When this button is pushed I want it to go to a scene in my storyboard. Here is the code that I've tried out that I thought would have worked:
if (b3.alpha>0.75 && CGRectContainsPoint(b3.frame, location))
{
[self performSegueWithIdentifier:#"News" sender:self];
}
I have a segue from the menu view controller to my news view controller with my Segue Identifier as News. My problem is that if I were push to the NewsViewController's class the news display doesn't register for some reason. It seemed that if i set the news scene to the initial view controller it works perfectly, and I've put a button on the scene temporarily and pushed from button to scene and that worked perfectly as well.
I've looked around for another solution but no matter what I try it either will not go to the scene in the storyboard or i'll keep getting libc++abi.dylib: terminating with uncaught exception of type NSException.
Any help would be appreciated!
I am using a Storyboard for the first time.
Here is a picture:
My app is a TabBar application. From the 'Main' screen I have a settings button, which I would like to connect to the SettingsViewController, which I have embedded in a Navigation Controller (because it has to continue in that manner - to other parts of the settings screen).
Another picture:
NOW: I have tried connecting the settings button (command+control drag) to the controller (modal segue)= CRASH. Tried to connect the settings controller (modal segue) = CRASH.
Tried programmatically : creating an IBAction for the settings button an then calling the settings VC, but that crashes too.
Note: This app has many many more screens, but they all work fine. It's just the connection to the Settings VC that Is crashing the app.
Any ideas would be appreciated.
Here is the error log:
So you get the error:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason:
'-[UITableViewController loadView] loaded the "Eab-23-IvL-view-eGY-e2-X6m" nib but didn't
get a UITableView.'
Which means that your Settings View Controller, which inherits from UITableViewController, does not have an actual UITableView in the storyboard. A fix that will definitely work is to just remove the settings view controller from the storyboard and then drag a Table View Controller in place of the one you removed. Then just proceed to give it the right class in the identity inspector and set back up all of the segues and connections!
You're using UIToolBar when there is a proper way to handle it, with UINavigationBar.
Then you can set a button, connect the button to settingViewController (control+drag), then choose modal, set a name to the segue, also control+drag the bar button item to your viewController and connect like this:
- (IBAction)btnSettings:(id)sender {
[self performSegueWithIdentifier:#"settingsSegue" sender:sender];
}
Then it should work.
I have a Master/Detail view which opens a popover view via storyboard segue. There is an add button on the navigation bar of the Master view controller which works fine.
I added an editing mode where the same popover is invoked by selecting a table cell in edit mode. It fails from the [self performSegueWithIdentifier:#"addQuery" sender:self]; statement. The viewDidLoad in the popover is invoked, but after that the exception is thrown.
I am not invoking presentPopoverFromBarButtonItem - it seems to be coming from the performSegueWithIdentifier.
There is no question that the Master View Controller has a window - a table cell for that view was clicked to start the whole process that is failing.
The popover is the beginning of a navigation controller sequence, which may be part of the problem. Everything is working fine when it really is invoked by the button, just trying to programmatically invoke it is failing.
I have tried changing the "sender" for the performSegueWithIdentifier to no avail.
I suspect the problem has to do with the segue not being invoked by a button, and I do not know how to fake that out.
Any ideas?
There appear to be some bugs in how ipad popover segue's work - see Wayne Hartman's blog post
A simple test revealed that viewWillAppear is being called after viewDidLoad.
I think I understand the problem... havent' worked out the solution yet.
The order in which the methods were called are...
[initiate segue]
viewDidLoad
prepareForSegue
viewWillAppear
I moved my initialization code to the viewWillAppear method - and it worked.
In general, I feel it may be a good idea to initialize within viewWillAppear instead of viewDidLoad anyway.
I have a similar issue:
I am using UIDocumentInteractionController to open a kaynote document in Kaynote app. I was using same code:
[docController presentOpenInMenuFromBarButtonItem:_actionBarButtonItem animated:YES];
Code above was opening popover from actiobBarButtonItem with options what app I would like to use to open my file. If I same thing from DetailViewController I get same error message as author of this thread: "Popovers cannot be presented from a view which does not have a window"
And I was able to find a quick solution for my issue . I am not sure if it will be relevant to yours. Instead of using "presentOpenInMenuFromBarButtonItem" I used "presentOpenInMenuFromRect" and thats it. You just need to define right place for popover to apear