i am using UIModalTransitionStylePartialCurl on the ios 4 device,in my test app i have 2 classes where a single button in each class, in first page onclick of the button it ill navigate to 2nd page (by curling the page up) but in the 2nd page when i click backbutton its crashing but not navigating back to my first page
following is my code used for navigation
ViewController *MainWin = [[QIAViewController alloc] initWithNibName:NULL bundle:NULL];
MainWin.modalTransitionStyle = UIModalTransitionStylePartialCurl;
[self presentModalViewController:MainWin animated:YES];
[MainWin release];
this is the crash log:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present a nested modal view controller while curled <QIAAdminPassCnf: 0x583e040>.'
*** Call stack at first throw:
If you read the documentation for UIModalTransitionStylePartialCurl, you will see that once you've used it you can't present any more modal views.
If you want to navigate back, I think you should do,
[self dismissModalViewControllerAnimated:YES];
rather than creating a new view controller instance.
You may well have added the Action twice in Interface Builder. Go to the ViewController and to the Triggered Segues on the right and "x" do delete the extra one. LOL
Related
I have an app using storyboard. The layout is: Nav Controller > Login View Controller > Tab Bar Controller and each tab has a Nav Controller pointing to the UIViewController for that tab. I'm trying to create a log out button that would remove the TabBarController and go back to the Login View Controller. My code is as per below:
// In log out function
[self.tabBarController dismissViewControllerAnimated:YES completion:nil];
[self performSelector:#selector(patchSelector) withObject:nil afterDelay:0.3];
-(void)patchSelector{
[self.tabBarController.navigationController popToRootViewControllerAnimated:YES];
}
I keep getting the following error:
*** Terminating app due to uncaught exception 'UIViewControllerHierarchyInconsistency', reason: 'presentedViewController for controller is itself on dismiss for
I tried reading the following regarding this:
No visible interface for dismissModalViewControllerAnimated:completion
http://www.touchthatfruit.com/viewwillappear-and-viewdidappear-not-being-ca
UITabbarController dismiss modal UINavigationController
However, none of the above helped with the error i'm getting. Is there something i'm missing in this? The error seems to indicate that the current vc is among those getting cleaned up.
When I remove my very first UINavigationController (the one before login screen) and I change the first line above to this: [self dismissModalViewControllerAnimated:YES];, it works...but only if I make it a modal segue. Easiest solution. Not sure why my original issue was, but i was able to get around it this way atleast!
i am developing an application which would have many subviews like the flow of instagram and picyou kind of social networking apps the flow is image->detail image->any comment->username->following->username->image username->image->detail image->any comment->username->following->username->image username->damn this is infinite never stops.....
and never gets memory warning or crashed by memory issue...
i am using navigation controller but still after some time of navigation changing some viewcontrollers it gives me error like this *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Pushing the same view controller instance more than once is not supported (<ViewController: 0x6d97110>)'
i want to do same like this on pressing back you will also get all datas back. do you have any idea how to do like this.?
UINavigationController automatically supports this behavior you are describing. Memory efficient and potentially infinite.
Every time you want to go from one piece of your app to the next you just use code similar to this.
ViewController *vc = [[ViewController alloc] init];
//customize ViewController
[self.navigationController pushViewController:vc animated:YES];
So if you want to go from a photo to a photo detail view, you just push the photo detail view controller when the button is pressed. Even if your in a photo detail view controller already you can push another one from that class. Just make sure you create a separate instance. Judging by your error, I think that is your problem now.
I have also found it best to create a custom initializer for these kinds of view controllers. For a photo detail view use something like.
-(id)initWithPhoto:(Photo*)photo;
I am trying to push a view from a button's IBAction and I am getting the following error:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[WebView initWithCoder:]: unrecognized selector sent to instance 0x68902b0'
Code:
-(IBAction)showWebsite:(id)sender {
NSLog(#"Web View!!!");
UIStoryboard* sb = [UIStoryboard storyboardWithName:#"MainStoryboard" bundle:nil];
UIViewController* vc = [sb instantiateViewControllerWithIdentifier:#"web"];
[self.navigationController pushViewController:vc animated:YES];
}
Any idea what could have gone wrong?
_(IBAction) is connected to TouchUpInside
Make sure the .h of the second view is imported into the .m of the first view.
If you are using storyboard and just want to switch from one view to another view via a button you can place a button on the first view drop a second uiview controller onto storyboard then right click on the button and drag the connection to the second view.
To go back to the first view, repeat the process only this time connect the button on the second page to the first view.
Goodday,
I got an application where an user logs in, and when the log in details is correct, the modalviewcontroller is dismissed. After the viewcontroller is dismissed, another view controller is called upon. This all goes fine except for the fact, when i want to switch back to my original controller: My login controller. I got the following code:
This code is called when the user logs in:
[self dismissModalViewControllerAnimated:YES];
Form *formcontroller1 = [[Form1 alloc] init];
[self presentModalViewViewController:formcontroller1 animated:YES];
After the user logged in, there is a logout button wich calls the following code:
[self dismissModalViewControllerAnimated:YES];
Postform3ViewController *logincontroller = [[Postform3ViewController alloc] init];
[self presentModalViewViewController:logincontroller animated:YES];
After the button is clicked, i get the following error message:
Postform3[5848:207] * Terminating app due to uncaught exception
'NSInternalInconsistencyException', reason: 'Attempting to begin a
modal transition from to while a transition is already in progress. Wait for
viewDidAppear/viewDidDisappear to know the current transition has
completed'
And i wonder if anyone can help me with this problem..
Actually, the error message tells you exactly what you need to do. You're dismissing a modal view controller, but not waiting until it's been dismissed before trying to present another. You should present the second view controller later, after -viewDidDisappear: has been invoked by the view controller machinery.
App Description: I have a UIWebview and a Toolbar beneath it. A button on the toolbar should bring up a modal table view, but it does not.
The toolbar has four buttons:
Previous: Goes to previous site
Next: Goes to the next site (these two being different than the default goForward and goBack methods)
Menu: Display a modalViewController with a TableView of all the available sites (sites will be limited to an array of site links that the next and previous buttons cycle through)
Refresh: Refreshes current site
Application has four main classes/files
WebAppDelegate.h and .m
ListViewController.h and .m (which has the Table View in its xib and the code to fill the table in the .m/ be the modal view controller)
There is only one warning and no errors.
Warning: 'WebAppDelegate' may not repsond to '-presentModalViewController:animated:'
When I run the program, everything is fine until I click the Menu button. I receive this runtime error
[WebAppDelegate presentModalViewController:animated:]: unrecognized selector sent to instance
Below is the code for the Menu button, which is currently in WebAppDelegate.m
-(IBAction)menu:(id)sender {
ListViewController *aListView=[[ListViewController alloc] initWithNibName:#"ListViewController" bundle:[NSBundle mainBundle]];
[self setListController:aListView];
aListView.modalTransitionStyle=UIModalTransitionStyleCoverVertical;
[self presentModalViewController:aListView animated:YES];
[aListView release];
}
Any ideas on what causes the application to crash and why the modal table view does not display?
The error message tells you exactly what your problem is - you're sending a selector to an object that doesn't respond to that selector.
[self presentModalViewController:aListView animated:YES];
self in this case in your instance of WebAppDelegate, which is probably a subclass of NSObject, not UIViewController. presentModalViewController:animated: is a method on UIViewController, so you need to send that message to whatever view controller is currently displayed (or perhaps a navigation controller) if you want to present another view controller modally.
Do not ignore compiler warnings - the one warning you have is likely telling you that...
'WebAppDelegate' may not respond to '-presentModalViewController:animated:'
...which, again, is exactly your problem.
[self.navigationController presentModalViewController:aListView animated:YES];