So I have a UITabView Controller that was created in interface builder. The title and image properties of UITabBarItem were set in IB. A Tab Bar Controller object is present in the xib and all necessary connections are made. I am able to call simple commands such as
[tabBarController setSelectedIndex:1];
Everything works fine but when I set the 'items' property, I crash. Maybe I am having a memory management problem?
Here is the crashing code:
NSMutableArray *modifiedItems = [[tabBarController.tabBar items] mutableCopy];
[modifiedItems removeObjectAtIndex:2];
NSArray *newItems = [[NSArray alloc] initWithArray:modifiedItems];
-->[tabBarController.tabBar setItems:newItems animated:NO];
* Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Directly modifying a tab bar managed by a tab bar controller is not allowed.'
* Call stack at first throw:
0 CoreFoundation 0x02b9bb99 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x02ceb40e objc_exception_throw + 47
2 CoreFoundation 0x02b54238 +[NSException raise:format:arguments:] + 136
3 CoreFoundation 0x02b541aa +[NSException raise:format:] + 58
4 UIKit 0x005f7019 -[UITabBar setItems:animated:] + 2037
5 Zag Map 0x00003422 -[ZagMapAppDelegate iPodTouchRemoval] + 270
6 Zag Map 0x00002eea -[ZagMapAppDelegate applicationDidFinishLaunching:] + 551
7 UIKit 0x003faf80 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1252
8 UIKit 0x003fd3b0 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 346
9 UIKit 0x004073ec -[UIApplication handleEvent:withNewEvent:] + 1958
10 UIKit 0x003ffb3c -[UIApplication sendEvent:] + 71
11 UIKit 0x004049bf _UIApplicationHandleEvent + 7672
12 GraphicsServices 0x03357822 PurpleEventCallback + 1550
13 CoreFoundation 0x02b7cff4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
14 CoreFoundation 0x02add807 __CFRunLoopDoSource1 + 215
15 CoreFoundation 0x02adaa93 __CFRunLoopRun + 979
16 CoreFoundation 0x02ada350 CFRunLoopRunSpecific + 208
17 CoreFoundation 0x02ada271 CFRunLoopRunInMode + 97
18 UIKit 0x003fcc6d -[UIApplication _run] + 625
19 UIKit 0x00408af2 UIApplicationMain + 1160
20 Zag Map 0x00002ca0 main + 102
21 Zag Map 0x00002c31 start + 53
terminate called after throwing an instance of 'NSException'
My NSArray and NSMutableArray appear to be fine considering they came straight out of the functioning UITabBar. It returned three objects, then two. I hope I'm just overlooking something stupid here. Any ideas I would really appreciate.
The exception message tells you exactly what is wrong:
'Directly modifying a tab bar managed by a tab bar controller is not allowed.'
Set the tab bar controller's viewControllers property instead.
NSMutableArray *viewControllersCopy = [[tabBarController viewControllers] mutableCopy];
[viewControllersCopy removeObjectAtIndex:2];
NSArray *modifiedViewControllers = [[NSArray alloc] initWithArray:viewControllersCopy];
[tabBarController setViewControllers:modifiedViewControllers animated:NO];
You can do like that-
tabBarController.selectedIndex = 1; // set index according to your requirement
Related
I'm using Xcode 4 and when I run my app, the first screen doesn't load. It fails in the simulators and on a device. I've searched for answers and they all say to make sure I've dragged the circles in Files Owner to the correct views. Sorry I don't remember the names of the things, I'm new to Xcode. I've dragged the circles to the correct view and tried many things but none of them worked. What could I be doing wrong?
Here is the full error:
2012-02-19 12:59:54.655 Ponyboard[271:207]
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException',
reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "PonyboardViewController" nib but the view outlet was not set.'
*** Call stack at first throw:
(
0 CoreFoundation 0x00f095a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x0105d313 objc_exception_throw + 44
2 CoreFoundation 0x00ec1ef8 +[NSException raise:format:arguments:] + 136
3 CoreFoundation 0x00ec1e6a +[NSException raise:format:] + 58
4 UIKit 0x0020d709 -[UIViewController _loadViewFromNibNamed:bundle:] + 295
5 UIKit 0x0020b134 -[UIViewController loadView] + 120
6 UIKit 0x0020b00e -[UIViewController view] + 56
7 UIKit 0x0017ed42 -[UIWindow addRootViewControllerViewIfPossible] + 51
8 Ponyboard 0x00002a87 -[PonyboardAppDelegate application:didFinishLaunchingWithOptions:] + 135
9 UIKit 0x0015bc89 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1163
10 UIKit 0x0015dd88 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 439
11 UIKit 0x00168617 -[UIApplication handleEvent:withNewEvent:] + 1533
12 UIKit 0x00160abf -[UIApplication sendEvent:] + 71
13 UIKit 0x00165f2e _UIApplicationHandleEvent + 7576
14 GraphicsServices 0x031fd992 PurpleEventCallback + 1550
15 CoreFoundation 0x00eea944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
16 CoreFoundation 0x00e4acf7 __CFRunLoopDoSource1 + 215
17 CoreFoundation 0x00e47f83 __CFRunLoopRun + 979
18 CoreFoundation 0x00e47840 CFRunLoopRunSpecific + 208
19 CoreFoundation 0x00e47761 CFRunLoopRunInMode + 97
20 UIKit 0x0015d7d2 -[UIApplication _run] + 623
21 UIKit 0x00169c93 UIApplicationMain + 1160
22 Ponyboard 0x000029c9 main + 121
23 Ponyboard 0x00002945 start + 53
)
terminate called after throwing an instance of 'NSException'
Are you sure you have a UIView (or subclass) assigned to the "view" property of PonyboardViewController? Right click on "File Owner" in the left pane of the xib for PonyboardViewController and verify that the "view" outlet is set.
If not, set it to a view!
I just have the same problem as you, so I fixed it like that:
this is my code block:
self.chatsView = [[ChatsView alloc] initWithNibName:#"ChatsView" bundle:nil];
I click ChatsView.xib to find the "File's owner", then hover my mouse over the "File's owner", and right click, that will prompt something like this:
The unconnected 'view' outlet
you must drag the "view" Outlet to connect to the View which have two subViews: Search Bar&Table View in my xib file.
The connected 'view' outlet
Your problem probably lies with the XIB or Stroyborad scene. Check whether the View is connected properly to the class.
I've tried, and it works fine for me after doing it.
I'm trying to add an ad package on an app. I've done it on another project, it worked. But here I'm having a mysterious error, that never happened before. Could you help me to trace it ?
Could you help me to trace this error ?
2011-08-29 13:22:12.012 MeoCampus[45962:207] -[AdRequest initWithPageId:formatId:master:target:creator:request:requestDelegate:]: unrecognized selector sent to instance 0x633aa20
2011-08-29 13:22:12.015 MeoCampus[45962:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[AdRequest initWithPageId:formatId:master:target:creator:request:requestDelegate:]: unrecognized selector sent to instance 0x633aa20'
*** Call stack at first throw:
(
0 CoreFoundation 0x018925a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x019e6313 objc_exception_throw + 44
2 CoreFoundation 0x018940bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x01803966 ___forwarding___ + 966
4 CoreFoundation 0x01803522 _CF_forwarding_prep_0 + 50
5 MeoCampus 0x000a1e92 -[SASApi downloadAdWithFormatId:pageId:master:target:creator:timeout:] + 235
6 MeoCampus 0x000a7a64 -[SmartAdServerView loadFormatId:pageId:master:target:timeout:] + 401
7 MeoCampus 0x000a7ab3 -[SmartAdServerView loadFormatId:pageId:master:target:] + 71
8 MeoCampus 0x00004623 -[HomeViewController viewDidLoad] + 483
9 UIKit 0x00c57089 -[UIViewController view] + 179
10 UIKit 0x00c55482 -[UIViewController contentScrollView] + 42
11 UIKit 0x00c65f25 -[UINavigationController _computeAndApplyScrollContentInsetDeltaForViewController:] + 48
12 UIKit 0x00c64555 -[UINavigationController _layoutViewController:] + 43
13 UIKit 0x00c65870 -[UINavigationController _startTransition:fromViewController:toViewController:] + 524
14 UIKit 0x00c6032a -[UINavigationController _startDeferredTransitionIfNeeded] + 266
15 UIKit 0x00d7b2e9 -[UILayoutContainerView layoutSubviews] + 226
16 QuartzCore 0x00203a5a -[CALayer layoutSublayers] + 181
17 QuartzCore 0x00205ddc CALayerLayoutIfNeeded + 220
18 QuartzCore 0x001ab0b4 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 310
19 QuartzCore 0x001ac294 _ZN2CA11Transaction6commitEv + 292
20 UIKit 0x00ba99c9 -[UIApplication _reportAppLaunchFinished] + 39
21 UIKit 0x00ba9e83 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 690
22 UIKit 0x00bb4617 -[UIApplication handleEvent:withNewEvent:] + 1533
23 UIKit 0x00bacabf -[UIApplication sendEvent:] + 71
24 UIKit 0x00bb1f2e _UIApplicationHandleEvent + 7576
25 GraphicsServices 0x02199992 PurpleEventCallback + 1550
26 CoreFoundation 0x01873944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
27 CoreFoundation 0x017d3cf7 __CFRunLoopDoSource1 + 215
28 CoreFoundation 0x017d0f83 __CFRunLoopRun + 979
29 CoreFoundation 0x017d0840 CFRunLoopRunSpecific + 208
30 CoreFoundation 0x017d0761 CFRunLoopRunInMode + 97
31 UIKit 0x00ba97d2 -[UIApplication _run] + 623
32 UIKit 0x00bb5c93 UIApplicationMain + 1160
33 MeoCampus 0x000023e9 main + 121
34 MeoCampus 0x00002365 start + 53
)
terminate called after throwing an instance of 'NSException'
Here is the code that create the ad:
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
//Intialize the SmartAdServerView object. This example is for a banner on the iPhone, you can specify any frame you want.
//By convention, banners have a ratio aspect of 6:1 in portrait mode, so if you have borders in your application, you should adapt the ad's height. The creative will be adapted to your view's frame, but it will look better if they have the same size.
//The iPad recommended height, with a 6:1 ratio is 128 pixels
SmartAdServerView *banner = [[SmartAdServerView alloc] initWithFrame:CGRectMake(.0,315.0,320.0,53.0) loader:SmartAdServerViewLoaderActivityIndicatorStyleWhite];
//Set an auto-resizing mask, for the view to adapt it's size when it's superview is resized (after a rotation for example). Typically a banner keep it's height and adapt it's width.
banner.autoresizingMask = UIViewAutoresizingFlexibleWidth;
//Set the banner to stay in place, so it won't be removed automatically.
banner.unlimited = YES;
//Set your ad's delegate, which will be the presentator of ad's modal view to the user, and will be notified of significative events
banner.delegate = self;
NSLog(#"set the delegate.");
NSLog(#"the delegate is = %#", [[banner delegate] class]);
//Load the ad with your settings
//The siteId can be a string in some rare cases, this is why you have to pass an NSString
//One ad per page of your application should have the "YES" for the "master" argument, and the other should have "NO", this is for page view counting.
//[banner loadFormatId:12345 pageId:#"98765" master:YES target:nil];
//Display the ad to the user, here we assume that we are in a UIViewController
[self.view addSubview:banner];
self.myAd = banner;
[banner release];
}
Thanks a lot.
I contacted the ad operator. Thanks you all.
Search for initWithPageId:formatId:master:target:creator:request:requestDelegate: method in your code. You are calling it for an object that does not recognize it.
I have created one navigation based application. In that first view show me the list of the drinks and in second view it show me the Details of the Drinks.
All seems ok but while i am navigatting the view at (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath Method, It will show me the error like
terminate called after throwing an instance of 'NSException'
at line
[self.navigationController pushViewController:drinkDetailViewController animated:YES];
Plese help me, why it happens like that ?
My code for the method is as follow:
(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
DrinkDetailViewController *drinkDetailViewController = [[DrinkDetailViewController alloc] initWithNibName:#"DrinkDetailViewController" bundle:nil];
//UINavigationController *navCon = [[UINavigationController alloc] initWithRootViewController:drinkDetailViewController];
//[self presentModalViewController:drinkDetailViewController animated:YES];
//[self dismissModalViewControllerAnimated:YES];
// ...
// Pass the selected object to the new view controller.
[self.navigationController pushViewController:drinkDetailViewController animated:YES];
[drinkDetailViewController release];
}
While i click on row, it shows me that exception message.
This is project log:
2011-08-10 10:18:10.559 DrinkMixer_Shreyash[694:207] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "DrinkDetailViewController" nib but the view outlet was not set.'
*** Call stack at first throw:
(
0 CoreFoundation 0x00dc25a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x00f16313 objc_exception_throw + 44
2 CoreFoundation 0x00d7aef8 +[NSException raise:format:arguments:] + 136
3 CoreFoundation 0x00d7ae6a +[NSException raise:format:] + 58
4 UIKit 0x000c6709 -[UIViewController _loadViewFromNibNamed:bundle:] + 295
5 UIKit 0x000c4134 -[UIViewController loadView] + 120
6 UIKit 0x000c400e -[UIViewController view] + 56
7 UIKit 0x000c2482 -[UIViewController contentScrollView] + 42
8 UIKit 0x000d2f25 -[UINavigationController _computeAndApplyScrollContentInsetDeltaForViewController:] + 48
9 UIKit 0x000d1555 -[UINavigationController _layoutViewController:] + 43
10 UIKit 0x000d27aa -[UINavigationController _startTransition:fromViewController:toViewController:] + 326
11 UIKit 0x000cd32a -[UINavigationController _startDeferredTransitionIfNeeded] + 266
12 UIKit 0x000d4562 -[UINavigationController pushViewController:transition:forceImmediate:] + 932
13 UIKit 0x000cd1c4 -[UINavigationController pushViewController:animated:] + 62
14 DrinkMixer_Shreyash 0x000029bf -[RootViewController tableView:didSelectRowAtIndexPath:] + 191
15 UIKit 0x0008bb68 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 1140
16 UIKit 0x00081b05 -[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 219
17 Foundation 0x0079b79e __NSFireDelayedPerform + 441
18 CoreFoundation 0x00da38c3 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 19
19 CoreFoundation 0x00da4e74 __CFRunLoopDoTimer + 1220
20 CoreFoundation 0x00d012c9 __CFRunLoopRun + 1817
21 CoreFoundation 0x00d00840 CFRunLoopRunSpecific + 208
22 CoreFoundation 0x00d00761 CFRunLoopRunInMode + 97
23 GraphicsServices 0x00ffa1c4 GSEventRunModal + 217
24 GraphicsServices 0x00ffa289 GSEventRun + 115
25 UIKit 0x00022c93 UIApplicationMain + 1160
26 DrinkMixer_Shreyash 0x00002089 main + 121
27 DrinkMixer_Shreyash 0x00002005 start + 53
28 ??? 0x00000001 0x0 + 1
)
terminate called after throwing an instance of 'NSException'
sharedlibrary apply-load-rules all
Current language: auto; currently objective-c
(gdb)
Please help me regarding it. . .
iDroid Exploer , in your drinkDetailViewController class you have to connect the view variable to the view element of the Xib file. It has to be done via interface builder.
This is the crash regarding that your IBOutlet for View in DrinkDetailViewController is not set in XIB file. Please set Your View in XIB and then try to run the app. This is done using Interface builder..
Happy Coding...
I have a very simple window based app, i am simply putting a navigation view controller as window's root view controller and it's crashing. This is the only thing i changed in the template project:
#interface AppDelegate : NSObject <UIApplicationDelegate> {
UINavigationController *navigationController;
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
navigationController = [[UINavigationController alloc] init];
[[self window] setRootViewController:navigationController];
[self.window makeKeyAndVisible];
return YES;
}
It crashes saying:
2011-05-26 20:18:57.194 ZebraSDKTest[5560:207] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UICustomObject 0x8b3d760> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key navigationController.'
*** Call stack at first throw:
(
0 CoreFoundation 0x00dbf5a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x00f13313 objc_exception_throw + 44
2 CoreFoundation 0x00dbf4e1 -[NSException raise] + 17
3 Foundation 0x00791677 _NSSetUsingKeyValueSetter + 135
4 Foundation 0x007915e5 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 285
5 UIKit 0x0020d30c -[UIRuntimeOutletConnection connect] + 112
6 CoreFoundation 0x00d358cf -[NSArray makeObjectsPerformSelector:] + 239
7 UIKit 0x0020bd23 -[UINib instantiateWithOwner:options:] + 1041
8 UIKit 0x0020dab7 -[NSBundle(UINSBundleAdditions) loadNibNamed:owner:options:] + 168
9 UIKit 0x0001317a -[UIApplication _loadMainNibFile] + 172
10 UIKit 0x00013cf4 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 291
11 UIKit 0x0001e617 -[UIApplication handleEvent:withNewEvent:] + 1533
12 UIKit
0x00016abf -[UIApplication sendEvent:] + 71
13 UIKit 0x0001bf2e _UIApplicationHandleEvent + 7576
14 GraphicsServices 0x00ff8992 PurpleEventCallback + 1550
15 CoreFoundation 0x00da0944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
16 CoreFoundation 0x00d00cf7 __CFRunLoopDoSource1 + 215
17 CoreFoundation 0x00cfdf83 __CFRunLoopRun + 979
18 CoreFoundation 0x00cfd840 CFRunLoopRunSpecific + 208
19 CoreFoundation 0x00cfd761 CFRunLoopRunInMode + 97
20 UIKit 0x000137d2 -[UIApplication _run] + 623
21 UIKit 0x0001fc93 UIApplicationMain + 1160
22 ZebraSDKTest 0x00002549 main + 121
23 ZebraSDKTest 0x000024c5 start + 53
)
Looks like you have a connection to a former existing UINavigationController IBOutlet in one of your nib files.
Start with MainWindow.xib and check for such a connection.
I had this problem occurring on the simulator only, but on the device it was working fine.
I tried cleaning the project, restarting Xcode, debugging, emptying the simulator data, the whole works.
In the end it was resolved by uninstalling the app from the simulator and reinstalling it. No idea why that worked, but it solved it!
here the situation: i have a viewcontroller which calls in the function "viewDidLoad" a function in the AppDelegateIphone to terminate this view.
The problem is that this exception comes if i make this:
splashScreen.view = nil;
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "SplashScreenController_iPhone" nib but the view outlet was not set.'
*** Call stack at first throw:
(
0 CoreFoundation 0x029dc919 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x02b2a5de objc_exception_throw + 47
2 CoreFoundation 0x02995078 +[NSException raise:format:arguments:] + 136
3 CoreFoundation 0x02994fea +[NSException raise:format:] + 58
4 UIKit 0x0062a09c -[UIViewController _loadViewFromNibNamed:bundle:] + 295
5 UIKit 0x00627cd1 -[UIViewController loadView] + 120
6 UIKit 0x00627bab -[UIViewController view] + 56
7 regioappv2 0x00003085 -[AppDelegate_iPhone application:didFinishLaunchingWithOptions:] + 97
8 UIKit 0x00580543 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1163
9 UIKit 0x005829a1 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 346
10 UIKit 0x0058c452 -[UIApplication handleEvent:withNewEvent:] + 1958
11 UIKit 0x00585074 -[UIApplication sendEvent:] + 71
12 UIKit 0x00589ac4 _UIApplicationHandleEvent + 7495
13 GraphicsServices 0x030bfafa PurpleEventCallback + 1578
14 CoreFoundation 0x029bddc4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
15 CoreFoundation 0x0291e737 __CFRunLoopDoSource1 + 215
16 CoreFoundation 0x0291b9c3 __CFRunLoopRun + 979
17 CoreFoundation 0x0291b280 CFRunLoopRunSpecific + 208
18 CoreFoundation 0x0291b1a1 CFRunLoopRunInMode + 97
19 UIKit 0x00582226 -[UIApplication _run] + 625
20 UIKit 0x0058db58 UIApplicationMain + 1160
21 regioappv2 0x000028b4 main + 102
22 regioappv2 0x00002845 start + 53
)
terminate called after throwing an instance of 'NSException'
Program received signal: “SIGABRT”.
if I call the function with the splashScreen.view = nil; in the appDelegate itself, then everything is working just fine.
Please tell me where is my fault, or wheather I should post more code.
regards
loaded the "SplashScreenController_iPhone" nib but the view outlet was not set.
Have you made the view outlet in interface builder? Seems that you have not set it up correctly. And also from the stack trace, it's clear that viewDidLoad haven't been called, as the view is yet to be successfully loaded.