How to add custom UITabbar in iOS7GM using xcode5 - iphone

Hello i am begginer in iOS I have created custom tabbar and add UIbar button items which are work properly in iOS 6 but in iOS 7 GM and Xcode 5 It Show Problem.....
This is my code for custom Tabbar ...
TabBar=[[UITabBar alloc]initWithFrame:CGRectMake(0, 480, 320, 80)];
TabBar.autoresizingMask =UIViewContentModeTopRight | UIViewAutoresizingFlexibleWidth;
TabBar.tintColor=[UIColor blackColor];
UIButton *btn1=[[UIButton alloc]initWithFrame:CGRectMake(0, 0, 20, 20)];
[btn1 setTitle:#"Charge Details" forState:UIControlStateNormal];
btn1.titleLabel.font=[UIFont boldSystemFontOfSize:10.0];
[btn1 addTarget:self action:#selector(ChargeDetails) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *button1 = [[UIBarButtonItem alloc]initWithCustomView:btn1];
UIButton *btn2=[[UIButton alloc]initWithFrame:CGRectMake(0,0,40,40)];
btn2.titleLabel.font=[UIFont boldSystemFontOfSize:10.0];
[btn2 setTitle:#"View Contact Details" forState:UIControlStateNormal];
[btn2 addTarget:self action:#selector(ViewContactDetails) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *button2 = [[UIBarButtonItem alloc]initWithCustomView:btn2];
TabBar.items=[NSArray arrayWithObjects:button1,button2,nil];
[self.view addSubview:TabBar];
This Code work in iOS 6 successfully but in iOS 7 GM I have problem ..actually custom Tabbar add on view successfully but when we add barbutton items this show error ...in this line
TabBar.items=[NSArray arrayWithObjects:button1,button2,nil];
and this is error ....
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIBarButtonItem _updateViewForIdiom:positionItems:]: unrecognized selector sent to instance 0xbd3c6c0'
*** First throw call stack:
(
0 CoreFoundation 0x04b9a5e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x018b58b6 objc_exception_throw + 44
2 CoreFoundation 0x04c37903 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x04b8a90b ___forwarding___ + 1019
4 CoreFoundation 0x04b8a4ee _CF_forwarding_prep_0 + 14
5 UIKit 0x006caefa -[UITabBar setItems:animated:] + 1218
6 UIKit 0x006c9d9c -[UITabBar setItems:] + 48
7 HISWebService 0x00021ee6 -[PatientLabDetailsViewController viewDidLoad] + 4566
8 UIKit 0x0052e9a8 -[UIViewController loadViewIfRequired] + 696
9 UIKit 0x0052ec44 -[UIViewController view] + 35
10 UIKit 0x00548a72 -[UINavigationController _startCustomTransition:] + 778
11 UIKit 0x00555757 -[UINavigationController _startDeferredTransitionIfNeeded:] + 688
12 UIKit 0x00556349 -[UINavigationController __viewWillLayoutSubviews] + 57
13 UIKit 0x0068f39d -[UILayoutContainerView layoutSubviews] + 213
14 UIKit 0x00485dd7 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
15 libobjc.A.dylib 0x018c781f -[NSObject performSelector:withObject:] + 70
16 QuartzCore 0x03e1172a -[CALayer layoutSublayers] + 148
17 QuartzCore 0x03e05514 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
18 QuartzCore 0x03e05380 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
19 QuartzCore 0x03d6d156 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 294
20 QuartzCore 0x03d6e4e1 _ZN2CA11Transaction6commitEv + 393
21 QuartzCore 0x03d6ebb4 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92
22 CoreFoundation 0x04b6253e __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
23 CoreFoundation 0x04b6248f __CFRunLoopDoObservers + 399
24 CoreFoundation 0x04b403b4 __CFRunLoopRun + 1076
25 CoreFoundation 0x04b3fb33 CFRunLoopRunSpecific + 467
26 CoreFoundation 0x04b3f94b CFRunLoopRunInMode + 123
27 GraphicsServices 0x01ab59d7 GSEventRunModal + 192
28 GraphicsServices 0x01ab57fe GSEventRun + 104
29 UIKit 0x0041b94b UIApplicationMain + 1225
30 HISWebService 0x0001f5fd main + 141
31 libdyld.dylib 0x051be725 start + 0
32 ??? 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Please solve my problem how to add custom button on UITabbar in iOS 7 GM ....
Thanks In advance!!!

From the Apple's Tabbar documentation:
A tab bar is a control, usually appearing across the bottom of the
screen in the context of a tab bar controller, for giving the user
one-tap, modal access to a set of views in an app. Each button in a
tab bar is called a tab bar item and is an instance of the
UITabBarItem class. If you instead want to give the user a bar of
buttons that each perform an action, use a UIToolbar object.
The UITabBar class supports user customization of a tab bar by
reordering, removing, and adding items to the bar. You can use a tab
bar delegate to augment this behavior.
Use the UITabBarItem class to create items and the setItems:animated:
method to add them to a tab bar. All methods with an animated:
argument allow you to optionally animate changes to the display. Use
the selectedItem property to access the current item.
You are using UIBarbuttonItems in a tab bar. If you want to use a tab bar use UITabBarItems.
However, seeing that you are adding actions to the buttons, you should be using a toolbar, not a tab bar. It should work peachy if you make these changes!

Related

Using UIAppearance with a subclass of UIBarButtonItem is causing unrecognized selector being sent to UINavigationButton

TL&DR;
Setting a custom property of a subclass of UIBarButtonItem using UIAppearance proxy is causing the "unrecognized selector" exception, beause the setter is probably being forwarded by UIAppearance to UINavigationButton, not the bar button itself.
SDK overview
I am using iOS 7 Beta 5 SDK with Xcode 5 DP5. But please, don't tell me that it is under NDA, because I do not discuss any new features or new classes in this question. I inform you of my SDK, because it can be found out that it's just a bug in the beta software.
What I did
I subclassed a UIBarButtonItem and created a custom property in the header file:
#property (nonatomic, strong) NSString *mySubclassedProperty UI_APPEARANCE_SELECTOR;
My setter and getter look like this:
- (void)setMySubclassedProperty:(NSString *)mySubclassedProperty {
_mySubclassedProperty = mySubclassedProperty;
NSLog(#"%p %s %#", self, __PRETTY_FUNCTION__, mySubclassedProperty);
}
Nothing special, huh? But it doesn't work with UIAppearance at all. When I try to set the default appearance in my application's delegate, it gives me no error, no warning, whatsoever.
[[AKBarButtonItem appearance] setMySubclassedProperty:#"GLOBALLY ASSIGNED"];
The crash
It seems to be working like a charm, except of the fact that it crashes when I try to set an instance of AKBarButtonItem to self.navigationItem.rightBarButtonItem:
self.navigationItem.rightBarButtonItem = [[AKBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:nil action:nil];
The backtrace looks like this:
2013-08-13 14:30:08.551 UIBarButtonItem Subclass Demo[1512:a0b] -[UINavigationButton setMySubclassedProperty:]: unrecognized selector sent to instance 0x8c42710
2013-08-13 14:30:08.556 UIBarButtonItem Subclass Demo[1512:a0b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UINavigationButton setMySubclassedProperty:]: unrecognized selector sent to instance 0x8c42710'
*** First throw call stack:
(
0 CoreFoundation 0x0173b6f4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x014bb8b6 objc_exception_throw + 44
2 CoreFoundation 0x017d8983 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x0172ba1b ___forwarding___ + 1019
4 CoreFoundation 0x0172b5fe _CF_forwarding_prep_0 + 14
5 CoreFoundation 0x0172fe2d __invoking___ + 29
6 CoreFoundation 0x0172fd3a -[NSInvocation invoke] + 362
7 CoreFoundation 0x0172feba -[NSInvocation invokeWithTarget:] + 74
8 UIKit 0x00763255 workaround10030904InvokeWithTarget + 824
9 UIKit 0x0075dea8 +[_UIAppearance _applyInvocationsTo:window:matchingSelector:] + 4497
10 UIKit 0x0075e299 +[_UIAppearance _applyInvocationsTo:window:] + 55
11 UIKit 0x0029ddcb -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 183
12 libobjc.A.dylib 0x014cd81f -[NSObject performSelector:withObject:] + 70
13 QuartzCore 0x03ac172a -[CALayer layoutSublayers] + 148
14 QuartzCore 0x03ab5514 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
15 QuartzCore 0x03ac3b55 -[CALayer(CALayerPrivate) layoutBelowIfNeeded] + 43
16 UIKit 0x00290886 -[UIView(Hierarchy) layoutBelowIfNeeded] + 595
17 UIKit 0x0029062d -[UIView(Hierarchy) layoutIfNeeded] + 74
18 UIKit 0x0050841e -[UIBarButtonItem(UIStatic) _leftRightImagePaddingForEdgeMarginInNavBarIsMini:] + 574
19 UIKit 0x002ea325 -[UINavigationBar _getTitleViewFrame:leftViewFrames:rightViewFrames:forItemAtIndex:returnedIdealWidthOfTextContent:availableLayoutWidthForTextContent:idealBackButtonWidth:] + 3522
20 UIKit 0x002ef2da -[UINavigationBar _getTitleViewFrame:leftViewFrames:rightViewFrames:forItemAtIndex:] + 591
21 UIKit 0x002ef59a -[UINavigationBar _getTitleViewFrame:leftViewFrames:rightViewFrames:] + 151
22 UIKit 0x002dc515 -[UINavigationBar _setLeftViews:rightViews:] + 1894
23 UIKit 0x002ca6c5 -[UINavigationItem updateNavigationBarButtonsAnimated:] + 188
24 UIKit 0x002cab63 -[UINavigationItem setObject:forLeftRightKeyPath:animated:] + 547
25 UIKit 0x002cb1ae -[UINavigationItem setRightBarButtonItem:animated:] + 171
26 UIKit 0x002cb0fe -[UINavigationItem setRightBarButtonItem:] + 48
27 UIBarButtonItem Subclass Demo 0x0000665e -[AKViewController viewDidLoad] + 222
28 UIKit 0x00345c18 -[UIViewController loadViewIfRequired] + 696
29 UIKit 0x00345eb4 -[UIViewController view] + 35
30 UIKit 0x00370369 -[UINavigationController rotatingSnapshotViewForWindow:] + 52
31 UIKit 0x00698e10 -[UIClientRotationContext initWithClient:toOrientation:duration:andWindow:] + 420
32 UIKit 0x00276ff2 -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:isRotating:] + 1495
33 UIKit 0x00276a16 -[UIWindow _setRotatableClient:toOrientation:updateStatusBar:duration:force:] + 82
34 UIKit 0x002768e8 -[UIWindow _setRotatableViewOrientation:updateStatusBar:duration:force:] + 117
35 UIKit 0x00276970 -[UIWindow _setRotatableViewOrientation:duration:force:] + 67
36 UIKit 0x00275a0a __57-[UIWindow _updateToInterfaceOrientation:duration:force:]_block_invoke + 120
37 UIKit 0x0027596c -[UIWindow _updateToInterfaceOrientation:duration:force:] + 400
38 UIKit 0x002766c3 -[UIWindow setAutorotates:forceUpdateInterfaceOrientation:] + 870
39 UIKit 0x00279c7e -[UIWindow setDelegate:] + 449
40 UIKit 0x0034a037 -[UIViewController _tryBecomeRootViewControllerInWindow:] + 180
41 UIKit 0x0026f91c -[UIWindow addRootViewControllerViewIfPossible] + 609
42 UIKit 0x00270146 -[UIWindow setRootViewController:] + 960
43 UIBarButtonItem Subclass Demo 0x00006a07 -[AKAppDelegate application:didFinishLaunchingWithOptions:] + 823
44 UIKit 0x0022d525 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 309
45 UIKit 0x0022dd65 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1536
46 UIKit 0x00232578 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 824
47 UIKit 0x0024657c -[UIApplication handleEvent:withNewEvent:] + 3447
48 UIKit 0x00246ae9 -[UIApplication sendEvent:] + 85
49 UIKit 0x002341f5 _UIApplicationHandleEvent + 736
50 GraphicsServices 0x0365a33b _PurpleEventCallback + 776
51 GraphicsServices 0x03659e46 PurpleEventCallback + 46
52 CoreFoundation 0x016b6e95 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
53 CoreFoundation 0x016b6bcb __CFRunLoopDoSource1 + 523
54 CoreFoundation 0x016e18ac __CFRunLoopRun + 2156
55 CoreFoundation 0x016e0bf3 CFRunLoopRunSpecific + 467
56 CoreFoundation 0x016e0a0b CFRunLoopRunInMode + 123
57 UIKit 0x00231cad -[UIApplication _run] + 840
58 UIKit 0x00233f0b UIApplicationMain + 1225
59 UIBarButtonItem Subclass Demo 0x00006e9d main + 141
60 libdyld.dylib 0x01d77725 start + 0
)
libc++abi.dylib: terminating with uncaught exception of type NSException
After some examination I strangly realized that the setMySubclassedProperty: message is sent to UINavigationButton (which is a private subclass of UIButton used in navigation bars, toolbars and search bars). I set the button in frame 26 and the UIAppearance magic is executed in frame 10.
In iOS 6, the issue exists but a different message is sent to UINavigationButton:
2013-08-13 14:35:58.316 UIBarButtonItem Subclass Demo[1591:c07] -[UINavigationButton _UIAppearance_setMySubclassedProperty:]: unrecognized selector sent to instance 0x810d600
2013-08-13 14:35:58.359 UIBarButtonItem Subclass Demo[1591:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UINavigationButton _UIAppearance_setMySubclassedProperty:]: unrecognized selector sent to instance 0x810d600'
*** First throw call stack:
(0x12b2012 0x10d7e7e 0x133d4bd 0x12a1bbc 0x12a194e 0x12a61bd 0x12a60d6 0x12a624a 0x68b9e8 0x68769c 0x687a95 0x291884 0x3088ca 0x28cf96 0x2934a4 0x28b89d 0x2cc646 0x2bc076 0x2bc517 0x2bcb66 0x2bcab6 0x665e 0x3261c7 0x326232 0x3264da 0x33d8e5 0x33d9cb 0x33dc76 0x33dd71 0x33e89b 0x33e9b9 0x33ea45 0x44420b 0x2952dd 0x10eb6b0 0x289dfc0 0x289233c 0x289deaf 0x3342bd 0x27cb56 0x27b66f 0x27b589 0x27a7e4 0x27a61e 0x27b3d9 0x27e2d2 0x32899c 0x275574 0x275cc1 0x6a07 0x242157 0x242747 0x24394b 0x254cb5 0x255beb 0x247698 0x24b8df9 0x24b8ad0 0x1227bf5 0x1227962 0x1258bb6 0x1257f44 0x1257e1b 0x24317a 0x244ffc 0x6e9d 0x1ab0725)
libc++abi.dylib: terminate called throwing an exception
Deduction
My first thought was: "UIAppearance forwards the setter to AKBarButtonItem and then it crashes". But does it? In an article by Peter Steinberger I found out that Apple is using a special subclass of _UIAppearance for bar items which is called _UIBarItemAppearance. I wanted to confirm that and set a symbolic breakpoint on -[_UIBarItemAppearance forwardInvocation:] and lldb successfully halted just before the exception occurred.
Now it seems to me that Apple is doing some dirty logic in -[_UIBarItemAppearance forwardInvocation:] to realize what selector should be sent to what instance, like:
setBackgroundImage:forState: should be sent to UINavigationButton
setBackButtonBackgroundImage:forState:barMetrics: to UIBarButtonItem
...
And their code looks like this:
if (selector == #selector(setBackButtonBackgroundImage:forState:barMetrics:)) {
// forward to UIBarButtonItem
} else if (selector == #selector(setBackButtonBackgroundVerticalPositionAdjustment:forBarMetrics:)) {
// forward to UIBarButtonItem
} else if (...) {
// more forwarding to UIBarButtonItem
} else {
// forward to UINavigationButton
}
Then, according to my deduction, the last else statement is causing setNiceBarButtonItemAttributes: selector being sent to UINavigationButton, not UIBarButtonItem. If it's true, we're doomed.
Sample code
You can download a sample project here: http://cl.ly/241I2A3U0a0y.
Help
Am I just doing something wrong, or is it a bug? Or maybe Apple did it on purpose? Any help would be appreciated.
The problem is UIBarButtonItem is not a subclass of UIView, it is a "controller" class which creates private UIView subclasses. For bar button items, there is a private appearance proxy which is used, instead of the usual one (some information here).
May I suggest going a different route? Do you really need to subclass bar button items for your customization? Could you not create a subclass of UINavigationBar and use that as your trigger for changes with appearanceWhenContainedIn:?
OK, I ended up using a customView. Seems that it's the only way..

Xcode "-[UIViewController _loadViewFromNibNamed:bundle:] loaded the nib but the view outlet was not set." error

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.

Unable to trace an error

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.

Getting SIGABRT for a reason unknown to me

I am developing an iOS application (http://affogato.visioa.com/) that implements a tab bar controller, navigation controller and a tableview controller and each time I run my application, I get: "Thread 1: Program recieved signal: "SIGABRT". Could anyone shed any light as to why I am getting this and how to correct it?
Below is the console:
2011-08-28 13:13:57.070 Affogato[16469:b303] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UITableViewController loadView] loaded the "CoffeesView" nib but didn't get a UITableView.'
*** Call stack at first throw:
(
0 CoreFoundation 0x00dc95a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x00f1d313 objc_exception_throw + 44
2 CoreFoundation 0x00d81ef8 +[NSException raise:format:arguments:] + 136
3 CoreFoundation 0x00d81e6a +[NSException raise:format:] + 58
4 UIKit 0x00224e9b -[UITableViewController loadView] + 275
5 UIKit 0x000cb00e -[UIViewController view] + 56
6 UIKit 0x000c9482 -[UIViewController contentScrollView] + 42
7 UIKit 0x000d9f25 -[UINavigationController _computeAndApplyScrollContentInsetDeltaForViewController:] + 48
8 UIKit 0x000d8555 -[UINavigationController _layoutViewController:] + 43
9 UIKit 0x000d9870 -[UINavigationController _startTransition:fromViewController:toViewController:] + 524
10 UIKit 0x000d432a -[UINavigationController _startDeferredTransitionIfNeeded] + 266
11 UIKit 0x001ef2e9 -[UILayoutContainerView layoutSubviews] + 226
12 QuartzCore 0x016b3a5a -[CALayer layoutSublayers] + 181
13 QuartzCore 0x016b5ddc CALayerLayoutIfNeeded + 220
14 QuartzCore 0x0165b0b4 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 310
15 QuartzCore 0x0165c294 _ZN2CA11Transaction6commitEv + 292
16 UIKit 0x0001d9c9 -[UIApplication _reportAppLaunchFinished] + 39
17 UIKit 0x0001de83 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 690
18 UIKit 0x00028617 -[UIApplication handleEvent:withNewEvent:] + 1533
19 UIKit 0x00020abf -[UIApplication sendEvent:] + 71
20 UIKit 0x00025f2e _UIApplicationHandleEvent + 7576
21 GraphicsServices 0x01002992 PurpleEventCallback + 1550
22 CoreFoundation 0x00daa944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
23 CoreFoundation 0x00d0acf7 __CFRunLoopDoSource1 + 215
24 CoreFoundation 0x00d07f83 __CFRunLoopRun + 979
25 CoreFoundation 0x00d07840 CFRunLoopRunSpecific + 208
26 CoreFoundation 0x00d07761 CFRunLoopRunInMode + 97
27 UIKit 0x0001d7d2 -[UIApplication _run] + 623
28 UIKit 0x00029c93 UIApplicationMain + 1160
29 Affogato 0x00001ed9 main + 121
30 Affogato 0x00001e55 start + 53
31 ??? 0x00000001 0x0 + 1
)
terminate called throwing an exception
The first line of your console log gives the reason for the SIGABRT:
2011-08-28 13:13:57.070 Affogato[16469:b303] *** Terminating app
due to uncaught exception 'NSInternalInconsistencyException',
reason: '-[UITableViewController loadView]
loaded the "CoffeesView" nib but didn't get a UITableView.'
If you intended to use a UITableViewController, it is looking in the NIB file for a UITableView to control - is there one there?
On the other hand, if you didn't mean to use this kind of controller, just change it to a UIViewController in the .h file.
I was getting the same error message and in my case the "view" outlet of table view was not connected in the storyboard scene. Control drag from ViewController object to the UITableView object embedded in the scene. HTH.
I had a same problem with the storyboard. the solution was very simple, In the storyboard, i was using the UIViewController class for my viewcontroller scene which should be actually UITableViewController. I just deleted my UIViewController scene and created new UITableViewController scene, the error went away.
I am pretty sure the same problem you have if you are using storyboard. If you are not using storyboard then make sure the class name you are setting in the XIB should be UITableViewController or Your custom class must inherit the UITableViewController in .h file and also make sure your view outlet set to your controller.
This error can also happen if you are using storyboards.
If you start a project as a universal app using storyboard then later change the project to support only in phone when you run the app on a iPad you may see this error.
To fix it temporally change the project back to universal and set the iPad storyboard to use the iPhone one, then set you project back to iPhone.
just an FYI
I think you should change:
[coffeeTypesArray objectAtIndex:row]
to
[coffeeTypesArray objectAtIndex:indexPath.row]

UITabBar – setItems:animated: Crashes

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