My app requires two separate split view controllers. First I created first split view controller that works fine , now added second split view controller but second split view controller causes crash.
in first split's master:
#property (nonatomic,strong) WODTutorialDetailsView *wods;
- (void)viewDidLoad
{
[super viewDidLoad];
//init detail instance
self.wods= (WODTutorialDetailsView *)[[self.splitViewController.viewControllers lastObject] topViewController];
[self populateTableview];
self.navigationItem.title = #"WODs";
}
in second split's master:
#property (nonatomic,strong) LogDetailViewController *wods;
- (void)viewDidLoad
{
[super viewDidLoad];
//init detail instance
self.wods= (LogDetailViewController *)[[self.splitViewController.viewControllers lastObject] topViewController];
[self populateTableview];
self.navigationItem.title = #"WODs";
}
Error I get is:
-[LogDetailViewController topViewController]: unrecognized selector sent to instance 0x229c4f40
2013-02-01 15:12:10.625 WOD Log[2473:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[LogDetailViewController topViewController]:
How can I make it work?
I have never heard of a good rational for this but Apple does say that a UISplitViewController should be the topmost UI Controller. Although this project is a bit old, its description is pretty clear in what it does:
Custom UISplitView which can be used with navigation based project.
Take a look:
https://github.com/palaniraja/cUISplitViewController
Related
I'm using payal iOS SDK and i want to go back to parent view controller in the function sendCompletedPaymentToServer using :
[self.navigationController popViewControllerAnimated:YES]
and :
[self dismissViewControllerAnimated:YES completion:nil]
app crashed.
ParentViewcontroller can be different.
it happens when i click on pay button for the second time.
ERROR Log :
2016-03-07 11:49:52.212 Ova[7169:2862312] Unbalanced calls to begin/end appearance transitions for .
2016-03-07 11:50:02.525 Ova[7169:2862312] * Terminating app due to uncaught exception 'NSRangeException', reason: '* -[__NSArray0 objectAtIndex:]: index 0 beyond bounds for empty NSArray'
*** First throw call stack:
(0x184915900 0x183f83f80 0x184891478 0x100145268 0x10014494c 0x100144ba4 0x10011a200 0x100116a9c 0x10010aafc 0x100150200 0x1010cdbf0 0x1010cdbb0 0x1010d3658 0x1848ccbb0 0x1848caa18 0x1847f9680 0x185d08088 0x189670d90 0x10006ec28 0x18439a8b8)
libc++abi.dylib: terminating with uncaught exception of type NSException
You are using :
[self.navigationController popViewControllerAnimated:YES];
This will bring you back to view controller. If you want to navigate back to previous view controller,you should implement :
[self.navigationController popToRootViewControllerAnimated:YES];
Resolved by adding BOOL variable to test if payment success or not. And into viewWillAppear i use:
[self.navigationController popViewControllerAnimated:YES];
thanks for all.
We also had same issue while integrating PayU gateway. I suggest you to use Protocol Delegate method to present view controller in which you are loading Payal in its web view.
Let second view controller is the one in which you are loading Payal and First view controller is presenting second view controller.
1. In Second view controller declare protocol that will dismiss secondviewcontroller
#protocol DismissPayalDelegate <NSObject>
#required
-(void)dismissPayal:(id)viewcontroller;
#end
#interface secondviewcontroller : UIViewController
#property(strong, nonatomic) id < DismissPayalDelegate > delegate;
#end
in secondviewcontroller.m file synthesize delegate object.In first view controller, If you are using performSegeuWithIdentifier (to present 2nd vc i.e Payal) then use get instance of destinationviewController i.e secondviewcontroller.
set destinationviewcontrollerInstance.delegate = self;
In secondViewController's Success/Failure method write code to dismiss view controller
[delegate dismissPayal:self];<br><br>
It will dismiss instance of second view controller that was presented in performSegueWithIdentifier methodUse this logic, I hope it helps you a lot.
Short version of question: When I pop a custom UIViewController that is parent to a UIPageViewController off a navigation stack, the app crashes - why and what's the workaround? Longer description below:
I have a login screen that then pushes on top a customer UIViewController which itself is the parent of a UIPageViewController that presents a UIPageView in a section of the parent controller's view. Let's call this custom UIViewController B, which is parent to a UIPageViewController as I said. Here are the parent view controller's properties as declared in the .h file for view controller B:
#interface bjViewController : UIPageViewController <UIPageViewControllerDelegate, UIPageViewControllerDataSource>
#property (strong, nonatomic) UIPageViewController *pageController;
#property (assign, nonatomic) NSInteger index;
#property (strong, nonatomic) UILabel *screenNumber;
#property UIPageControl *childPageControl;
#end
And here is the troublesome code in viewDidLoad for view controller B:
UIViewController *initialViewController = [self viewControllerAtIndex:0];
NSArray *viewControllers = [NSArray arrayWithObject:initialViewController];
[self.pageController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];
[self addChildViewController:self.pageController];
[[self view] addSubview:[self.pageController view]];
If I comment this out, I can pop this view controller off the UINavigationController stack without a problem back to UIViewController A, but with these lines in, the app crashes when I navigate back to view controller A. However if I navigate back to A after popping something else on instead of B, there is no problem, so I'm fairly sure the crash has something to do with these lines I've pasted above.
What happens with the crash is that the app does re-present the view from A but then gives an NSException error without indicating where it's crashing (and I have NSLog in all my functions for that view controller - none of those functions are being executed).
Here's the error I get. Yes I do have a breakpoint for all exceptions but it just dumps to the #implementation line in the .m file for B, even as it's already presenting A. Here's the error it gives:
2015-04-21 10:08:14.958 [953:110883] -[UIView invalidatePageViewController]: unrecognized selector sent to instance 0x1655e940
2015-04-21 10:08:49.375 [953:110883] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView invalidatePageViewController]: unrecognized selector sent to instance 0x1655e940'
*** First throw call stack:
(0x26a0845f 0x3489ec8b 0x26a0d879 0x26a0b797 0x2693d008 0x2a4a08fb 0x2690effd 0x2692614d 0x348b8d5f 0x2a091e9d 0x2a4a0981 0x53e95 0x3489dda1 0x348a75f7 0x348a761b 0x2a225435 0x2a0921e9 0x2a4a0981 0x2a181cd7 0x34e45ae1 0x29f58e75 0x348b8d5f 0x2690effd 0x26928df3 0x348b8d5f 0x348b91a9 0x2691a139 0x269ccd1f 0x2691a3b1 0x2691a1c3 0x2df47201 0x29f8443d 0x7379d 0x34e2aaaf)
libc++abi.dylib: termina
Has anyone run into something like this? Can you tell me what I'm doing wrong? I understand the basics of NSException and NSInvalidArgumentException, but I don't even know what's being called/incorrectly called.
In my storyboard I have 2 views one master and one detail with list. I want to show detail view on master. When I add detail to master like that:
- (void)viewDidLoad
{
[super viewDidLoad];
tableViewController = [[TableViewController alloc] init];
[self addChildViewController:detailVC];
[self.view addSubview:detailVC.view];
}
I get crash like that:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:'
Im sure that there is everything ok with my table viewController becouse when I set it to rootViewController there is everything ok. What I'm doing wrong?
Looks like its an issue with tableview delegate methods. In story board please use static cell for your table view controller and remove table view delegate methods or else implement all required table view delegate methods.
My iPad application has a SplitViewController, a MasterViewController and a DetailViewController. From the DetailViewController, I need to create a temporary view (managed with a PaletteViewController: UIViewController, and designed in a xib file) that the user can move on the screen to be able to see what content is backwards.
in DetailViewController.m:
#synthesize paletteViewController=_paletteViewController;
(...)
- (IBAction) loadPalette: (id) sender{
if (_paletteViewController == nil) {
self.paletteViewController = [[PaletteViewController alloc] init];
}
self.paletteViewController.delegate=self;
[self.paletteViewController setModalPresentationStyle:UIModalPresentationFormSheet];
[self presentModalViewController:self.paletteViewController animated:YES];
(...)
I get an error message: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present modally an active controller .
Any idea?
I think you are in your paletteViewController and you are presenting modally paletteViewController over plaetteViewController . how is it possible.you can present paletteViewController over detailview or something(some paarent view).
I'm trying to have a Terms of Service modal view display when my application launches, when the settings preference indicates the user hasn't accepted the terms of use.
So in my appDelegate in the ApplicationDidFinishLaunchingWithOptions, I have this code:
if (TOSAcceptedPrefValue) { //has not been accepted
// Create the root view controller for the navigation controller
TermsOfServiceController *termsOfServiceController = [[TermsOfServiceController alloc]
initWithNibName:#"TermsOfServiceController" bundle:nil];
// Create the navigation controller and present it modally.
UINavigationController *navigationController = [[UINavigationController alloc]
initWithRootViewController:termsOfServiceController];
termsOfServiceController.delegate = self;
navigationController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:navigationController animated:YES];
[navigationController release];
[TermsOfServiceController release];
NSLog(#"1");
}
However, Xcode is indicating that termsOfServiceController.delegate = self is "Assigning to 'id' from imcompatible type 'MyAppAppDelegate *' ".
I think I fully implement the modal protocol in my AppDelegate header:
#protocol TOSModalViewDelegate
- (void)didAcceptTermsOfService:(NSString *)message;
- (void)didRejectTermsOfService:(NSString *)message;
#end
#interface MyAppAppDelegate : NSObject <UIApplicationDelegate, TOSModalViewDelegate> ...
and in the modalview header:
#protocol ModalViewDelegate ;
#interface TermsOfServiceController : UIViewController {
id<ModalViewDelegate> delegate; ...
...
#property (nonatomic, assign) id<ModalViewDelegate> delegate;
and I synthesize it in the modalview implemenation file.
Per this example, I moved my code in the AppDelegate.m file to after the window get instantiated but still have the warning from Xcode.
The warning results in an app crash with this error:
2011-09-05 08:34:12.237 MyApp[4416:207] TOSAcceptedPrefValue = 0
2011-09-05 08:34:13.732 MyApp[4416:207] displayWelcomeScreenPrefValue = 0
2011-09-05 08:34:42.889 MyApp[4416:207] -[MyAppAppDelegate presentModalViewController:animated:]: unrecognized selector sent to instance 0x552b430
2011-09-05 08:34:42.892 MyApp[4416:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[MyAppAppDelegate presentModalViewController:animated:]: unrecognized selector sent to instance 0x552b430'
So my question is, is it possible to display a modal view from the appdelegate and if so, what should I change to make it happen.
Thanks for your help
The error is because MyAppAppDelegate isn't a UIViewController subclass, and therefore can't handle presentModalViewController:animated:.
So no, your app delegate can't present a modalViewController, it has to be presented by a real view controller. This isn't hard to do, just create one that shows your terms in viewDidLoad, and responds appropriately when the modal controller exits, to do whatever you need to do next.