Present UIViewController from subclass of UIView - ios

I have created a subclass of UIView, Now in my app i need to present a UIViewController from it,
I have tried following :
poiInfoController = [[poiInfoController alloc]initWithNibName:#"poiInfoController" bundle:nil];
[poiInfoController setModalPresentationStyle:UIModalPresentationFormSheet];
[[[[UIApplication sharedApplication] keyWindow] rootViewController] presentModalViewController:poiInfoController animated:YES];
but it will crash with Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present modally an active controller .'
Please Help,
**EDIT CRASH LOG:**
2014-04-23 17:04:26.433 NavigationLibSprintMoM[4610:a0b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present modally an active controller <ViewController: 0x9d52140>.'
*** First throw call stack:
(
0 CoreFoundation 0x017c15e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x014d08b6 objc_exception_throw + 44
2 UIKit 0x0036217a -[UIViewController presentViewController:withTransition:completion:] + 4879
3 UIKit 0x00362caf -[UIViewController presentViewController:animated:completion:] + 130
4 NavigationLibSprintMoM 0x00005f7b -[NavigationView handleGesture:] + 964
5 UIKit 0x005baf8c _UIGestureRecognizerSendActions + 230
6 UIKit 0x005b9c00 -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:] + 383
7 UIKit 0x005bb66d -[UIGestureRecognizer _delayedUpdateGesture] + 60
8 UIKit 0x005bebcd ___UIGestureRecognizerUpdate_block_invoke + 57
9 UIKit 0x005beb4e _UIGestureRecognizerRemoveObjectsFromArrayAndApplyBlocks + 317
10 UIKit 0x005b5248 _UIGestureRecognizerUpdate + 199
11 UIKit 0x00281d4a -[UIWindow _sendGesturesForEvent:] + 1291
12 UIKit 0x00282c6a -[UIWindow sendEvent:] + 1030
13 UIKit 0x00256a36 -[UIApplication sendEvent:] + 242
14 UIKit 0x00240d9f _UIApplicationHandleEventQueue + 11421
15 CoreFoundation 0x0174a8af __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
16 CoreFoundation 0x0174a23b __CFRunLoopDoSources0 + 235
17 CoreFoundation 0x0176730e __CFRunLoopRun + 910
18 CoreFoundation 0x01766b33 CFRunLoopRunSpecific + 467
19 CoreFoundation 0x0176694b CFRunLoopRunInMode + 123
20 GraphicsServices 0x038699d7 GSEventRunModal + 192
21 GraphicsServices 0x038697fe GSEventRun + 104
22 UIKit 0x0024394b UIApplicationMain + 1225
23 NavigationLibSprintMoM 0x0000374d main + 141
24 libdyld.dylib 0x01f54725 start + 0
25 ??? 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

Related

Uncaught exception 'NSInvalidArgumentException',reason: 'Receiver .. has no segue'

I just started recently. I can't fix it and I don't know How to do
I have attached files and images. When I run my app, I receive the following error:
2015-11-26 12:17:08.175 login[6107:324531]
*** Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: 'Receiver (<login.ViewController: 0x7fc0d94b28d0>)
has no segue with identifier 'loginView''
*** First throw call stack:
(
0 CoreFoundation 0x0000000100457f45 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010217bdeb objc_exception_throw + 48
2 UIKit 0x0000000100e099ea -[UIViewController shouldPerformSegueWithIdentifier:sender:] + 0
3 login 0x000000010025fc85 _TFC5login14ViewController13viewDidAppearfS0_FSbT_ + 309
4 login 0x000000010025fce1 _TToFC5login14ViewController13viewDidAppearfS0_FSbT_ + 49
5 UIKit 0x0000000100e0c675 -[UIViewController _setViewAppearState:isAnimating:] + 830
6 UIKit 0x0000000100e0cff8 -[UIViewController _endAppearanceTransition:] + 262
7 UIKit 0x0000000100e47a00 -[UINavigationController navigationTransitionView:didEndTransition:fromView:toView:] + 1290
8 UIKit 0x0000000100e3d917 __49-[UINavigationController _startCustomTransition:]_block_invoke + 233
9 UIKit 0x000000010166db24 -[_UIViewControllerTransitionContext completeTransition:] + 101
10 UIKit 0x0000000100c5cf4a __53-[_UINavigationParallaxTransition animateTransition:]_block_invoke93 + 834
11 UIKit 0x0000000100d1eace -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 644
12 UIKit 0x0000000100cfc9df -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 241
13 UIKit 0x0000000100cfcd8e -[UIViewAnimationState animationDidStop:finished:] + 80
14 QuartzCore 0x00000001051b9fa0 _ZN2CA5Layer23run_animation_callbacksEPv + 308
15 libdispatch.dylib 0x0000000102c4f49b _dispatch_client_callout + 8
16 libdispatch.dylib 0x0000000102c372af _dispatch_main_queue_callback_4CF + 1738
17 CoreFoundation 0x00000001003b82e9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
18 CoreFoundation 0x00000001003798a9 __CFRunLoopRun + 2073
19 CoreFoundation 0x0000000100378e08 CFRunLoopRunSpecific + 488
20 GraphicsServices 0x0000000104a4bad2 GSEventRunModal + 161
21 UIKit 0x0000000100c7430d UIApplicationMain + 171
22 login 0x00000001002630dd main + 109
23 libdyld.dylib 0x0000000102c8392d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
My screenshots of code are here:
Screenshots of code
Your error tells you exactly what you need to do.
Receiver (<login.ViewController: 0x7fc0d94b28d0>) has no segue with identifier 'loginView'
so check your segue in storyboard and ensure that segue identifier from LoginViewController is loginView.

ibc++abi.dylib: terminating with uncaught exception of type NSException (lldb)

when i run my app, i received this error :
2014-11-10 06:14:05.581 Yoga[4032:110484] user is registered
2014-11-10 06:14:30.552 Yoga[4032:110484] * 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.'
* First throw call stack:
(
0 CoreFoundation 0x000000010c999f35 exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010c632bb7 objc_exception_throw + 45
2 UIKit 0x000000010b43e16a -[UIStoryboardPushSegue destinationContainmentContext] + 0
3 UIKit 0x000000010aedc8be -[UIApplication sendAction:to:from:forEvent:] + 75
4 UIKit 0x000000010afe3410 -[UIControl _sendActionsForEvents:withEvent:] + 467
5 UIKit 0x000000010afe27df -[UIControl touchesEnded:withEvent:] + 522
6 UIKit 0x000000010af22308 -[UIWindow _sendTouchesForEvent:] + 735
7 UIKit 0x000000010af22c33 -[UIWindow sendEvent:] + 683
8 UIKit 0x000000010aeef9b1 -[UIApplication sendEvent:] + 246
9 UIKit 0x000000010aefca7d _UIApplicationHandleEventFromQueueEvent + 17370
10 UIKit 0x000000010aed8103 _UIApplicationHandleEventQueue + 1961
11 CoreFoundation 0x000000010c8cf551 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17
12 CoreFoundation 0x000000010c8c541d __CFRunLoopDoSources0 + 269
13 CoreFoundation 0x000000010c8c4a54 __CFRunLoopRun + 868
14 CoreFoundation 0x000000010c8c4486 CFRunLoopRunSpecific + 470
15 GraphicsServices 0x000000010d3329f0 GSEventRunModal + 161
16 UIKit 0x000000010aedb420 UIApplicationMain + 1282
17 Yoga 0x000000010a840b53 main + 115
18 libdyld.dylib 0x000000010f69b145 start + 1
19 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
somebody can help me pls
add Navigation Controller to your initial view
Select the initial view
Go To Editor--> Embed In --> Navigation Controller.

Tableview / ScrollView within the UIPageController cause crash while navigating to next Page

I have a UIPageViewController which holds two screens.
self.pageController = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:nil];
And one of the screen contains tableview on iphone /Collection view on ipad.On some user event we are setting the contentOfset to move the tableview a bit up
[table setContentOffset:cell.frame.origin animated:YES];
Then user navigates to next screen using UIPageviewcontroller
Above usecase causes crash on the app with the following logs
2014-11-14 09:04:46.783 tibbr[12329:79833] *** Assertion failure in -[_UIQueuingScrollView _setWrappedViewAtIndex:withView:], /SourceCache/UIKit_Sim/UIKit-3318.16.14/_UIQueuingScrollView.m:338
2014-11-14 09:04:46.786 tibbr[12329:79833] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Unexpected subviews'
*** First throw call stack:
(
0 CoreFoundation 0x0000000113512f35 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000111be7bb7 objc_exception_throw + 45
2 CoreFoundation 0x0000000113512d9a +[NSException raise:format:arguments:] + 106
3 Foundation 0x00000001115c15df -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 195
4 UIKit 0x00000001108715e0 -[_UIQueuingScrollView _setWrappedViewAtIndex:withView:] + 215
5 UIKit 0x0000000110871b0a -[_UIQueuingScrollView _replaceViews:updatingContents:adjustContentInsets:animated:] + 672
6 UIKit 0x0000000110873e57 -[_UIQueuingScrollView setView:direction:animated:completion:] + 524
7 UIKit 0x00000001107d5e16 -[UIPageViewController _setViewControllers:withScrollInDirection:animated:completion:] + 483
8 UIKit 0x00000001107d5f78 -[UIPageViewController setViewControllers:direction:animated:completion:] + 157
12 UIKit 0x000000011024e8be -[UIApplication sendAction:to:from:forEvent:] + 75
13 UIKit 0x0000000110355410 -[UIControl _sendActionsForEvents:withEvent:] + 467
14 UIKit 0x00000001103cf9ea -[UISegmentedControl _setSelectedSegmentIndex:notify:animate:] + 570
15 UIKit 0x00000001103d1a0f -[UISegmentedControl touchesEnded:withEvent:] + 143
16 UIKit 0x00000001105fb540 _UIGestureRecognizerUpdate + 9487
17 UIKit 0x0000000110293ff6 -[UIWindow _sendGesturesForEvent:] + 1041
18 UIKit 0x0000000110294c23 -[UIWindow sendEvent:] + 667
19 UIKit 0x00000001102619b1 -[UIApplication sendEvent:] + 246
20 UIKit 0x000000011026ea7d _UIApplicationHandleEventFromQueueEvent + 17370
21 UIKit 0x000000011024a103 _UIApplicationHandleEventQueue + 1961
22 CoreFoundation 0x0000000113448551 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
23 CoreFoundation 0x000000011343e41d __CFRunLoopDoSources0 + 269
24 CoreFoundation 0x000000011343da54 __CFRunLoopRun + 868
25 CoreFoundation 0x000000011343d486 CFRunLoopRunSpecific + 470
26 GraphicsServices 0x0000000113e859f0 GSEventRunModal + 161
27 UIKit 0x000000011024d420 UIApplicationMain + 1282
28 tibbr 0x000000010cb942d1 tibbr + 58065
29 libdyld.dylib 0x0000000112660145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Kindly do suggest me what could be root cause of this issue

NSInvalidArgumentException', reason: 'Receiver (<ViewController:>) has no segue with identifier '''

> 2014-09-20 18:04:45.564 storyboard_demo[6919:60b] nested push
animation can result in corrupted navigation bar 2014-09-20
18:04:45.921 storyboard_demo[6919:60b] Finishing up a navigation
transition in an unexpected state. Navigation Bar subview tree might
get corrupted. 2014-09-20 18:04:46.442 storyboard_demo[6919:60b] *
Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: 'Receiver
() has no segue with identifier
'third''
* First throw call stack: ( 0 CoreFoundation 0x017ed1e4 exceptionPreprocess + 180 1 libobjc.A.dylib
0x0156c8e5 objc_exception_throw + 44 2 UIKit
0x0034d48c -[UIViewController
shouldPerformSegueWithIdentifier:sender:] + 0 3 storyboard_demo
0x0000254e -[secondViewController btn_second:] + 110 4
libobjc.A.dylib 0x0157e880 -[NSObject
performSelector:withObject:withObject:] + 77 5 UIKit
0x0022e3b9 -[UIApplication sendAction:to:from:forEvent:] + 108 6
UIKit 0x0022e345 -[UIApplication
sendAction:toTarget:fromSender:forEvent:] + 61 7 UIKit
0x0032fbd1 -[UIControl sendAction:to:forEvent:] + 66 8 UIKit
0x0032ffc6 -[UIControl _sendActionsForEvents:withEvent:] + 577 9
UIKit 0x0032f243 -[UIControl
touchesEnded:withEvent:] + 641 10 UIKit
0x0026dddd -[UIWindow _sendTouchesForEvent:] + 852 11 UIKit
0x0026e9d1 -[UIWindow sendEvent:] + 1117 12 UIKit
0x002405f2 -[UIApplication sendEvent:] + 242 13 UIKit
0x0022a353 _UIApplicationHandleEventQueue + 11455 14 CoreFoundation
0x0177677f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION
+ 15 15 CoreFoundation 0x0177610b __CFRunLoopDoSources0 + 235 16 CoreFoundation 0x017931ae __CFRunLoopRun + 910 17 CoreFoundation
0x017929d3 CFRunLoopRunSpecific + 467 18 CoreFoundation
0x017927eb CFRunLoopRunInMode + 123 19 GraphicsServices
0x037e15ee GSEventRunModal + 192 20 GraphicsServices
0x037e142b GSEventRun + 104 21 UIKit
0x0022cf9b UIApplicationMain + 1225 22 storyboard_demo
0x00002e4d main + 141 23 libdyld.dylib
0x01e3470d start + 1 24 ???
0x00000001 0x0 + 1 ) libc++abi.dylib: terminating with uncaught
exception of type NSException
(lldb)
Do it in two steps.
btn_second: can post a notification that it has been pressed and then return to 'first'. 'first' receives the notification and sets a flag. In viewWillAppear, 'first' checks the flag and does a 'third' segue if it's set.

Objective-C: unrecognized selector sent to instance 0xba3e750

I have written this code and when I run the program it throws exception: unrecognized selector sent to instance 0xba3e750
storyboard = [UIStoryboard storyboardWithName:#"Main" bundle:nil];
navigationController = [storyboard instantiateViewControllerWithIdentifier:#"SecondViewID"];
selected = navigationController.viewControllers[0];
when I put this line in comment
//selected = navigationController.viewControllers[0];
like that , the program doesn't throw exception.
this is whole exception
2014-06-12 20:59:44.749 passing image[2194:a0b] -[SecondViewController viewControllers]: unrecognized selector sent to instance 0xba3e750
2014-06-12 20:59:44.753 passing image[2194:a0b] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[SecondViewController viewControllers]: unrecognized selector sent to instance 0xba3e750'
* First throw call stack:
(
0 CoreFoundation 0x017445e4 exceptionPreprocess + 180
1 libobjc.A.dylib 0x014c78b6 objc_exception_throw + 44
2 CoreFoundation 0x017e1903 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x0173490b ___forwarding_ + 1019
4 CoreFoundation 0x017344ee _CF_forwarding_prep_0 + 14
5 passing image 0x000056a2 -[ViewController viewDidLoad] + 466
6 UIKit 0x00349318 -[UIViewController loadViewIfRequired] + 696
7 UIKit 0x003495b4 -[UIViewController view] + 35
8 UIKit 0x002719fd -[UIWindow addRootViewControllerViewIfPossible] + 66
9 UIKit 0x00271d97 -[UIWindow _setHidden:forced:] + 312
10 UIKit 0x0027202d -[UIWindow _orderFrontWithoutMakingKey] + 49
11 UIKit 0x0027c89a -[UIWindow makeKeyAndVisible] + 65
12 UIKit 0x0022fcd0 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1851
13 UIKit 0x002343a8 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 824
14 UIKit 0x0024887c -[UIApplication handleEvent:withNewEvent:] + 3447
15 UIKit 0x00248de9 -[UIApplication sendEvent:] + 85
16 UIKit 0x00236025 _UIApplicationHandleEvent + 736
17 GraphicsServices 0x037932f6 _PurpleEventCallback + 776
18 GraphicsServices 0x03792e01 PurpleEventCallback + 46
19 CoreFoundation 0x016bfd65 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION + 53
20 CoreFoundation 0x016bfa9b __CFRunLoopDoSource1 + 523
21 CoreFoundation 0x016ea77c __CFRunLoopRun + 2156
22 CoreFoundation 0x016e9ac3 CFRunLoopRunSpecific + 467
23 CoreFoundation 0x016e98db CFRunLoopRunInMode + 123
24 UIKit 0x00233add -[UIApplication _run] + 840
25 UIKit 0x00235d3b UIApplicationMain + 1225
26 passing image 0x0000750d main + 141
27 libdyld.dylib 0x01e78725 start + 0
28 ??? 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
instantiateViewControllerWithIdentifier: returns a UIViewController, but you're storing it in a UINavigationController when you shouldn't. When you try to access a UINavigationController property (viewControllers), it crashed because UIViewController doesn't have a property named viewControllers.
Try storing the return of the method instantiateViewControllerWithIdentifier: in a UIViewController instead of a UINavigationController :
UIViewController * viewController = [storyboard instantiateViewControllerWithIdentifier:#"SecondViewID"];
selected = viewController.navigationController.viewControllers[0];

Resources