My application doesn't open after trying to implement iAds! - iphone

I have been trying to implement iAds into my application, but this is what happens:
1.Tap on app
2.Loading Screen Displayed for a few seconds
3.App Crashes
This is whats returned:
2010-11-06 20:19:11.043 Vampire Quiz
Final[99722:207] Unknown class
AdViewController in Interface Builder
file. 2010-11-06 20:19:11.066 Vampire
Quiz Final[99722:207]
-[Vampire_Quiz_FinalViewController setBannerIsVisible:]: unrecognized
selector sent to instance 0x761c710
2010-11-06 20:19:11.409 Vampire Quiz
Final[99722:207] * Terminating app
due to uncaught exception
'NSInvalidArgumentException',
reason:
'-[Vampire_Quiz_FinalViewController
setBannerIsVisible:]: unrecognized
selector sent to instance 0x761c710'
* Call stack at first throw: ( 0 CoreFoundation
0x02a88b99 exceptionPreprocess + 185
1 libobjc.A.dylib
0x02bd840e objc_exception_throw + 47
2 CoreFoundation
0x02a8a6ab -[NSObject(NSObject)
doesNotRecognizeSelector:] + 187 3
CoreFoundation
0x029fa2b6 __forwarding + 966 4
CoreFoundation
0x029f9e72 _CF_forwarding_prep_0 + 50
5 Vampire Quiz Final
0x000027a2
-[Vampire_Quiz_FinalViewController viewDidLoad] + 601 6 UIKit
0x003715ca -[UIViewController view] +
179 7 Vampire Quiz Final
0x000021b1
-[Vampire_Quiz_FinalAppDelegate application:didFinishLaunchingWithOptions:]
+ 74 8 UIKit 0x002c7f27 -[UIApplication
_callInitializationDelegatesForURL:payload:suspended:]
+ 1163 9 UIKit 0x002ca3b0 -[UIApplication
_runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:]
+ 346 10 UIKit 0x002d43ec -[UIApplication
handleEvent:withNewEvent:] + 1958 11
UIKit
0x002ccb3c -[UIApplication sendEvent:]
+ 71 12 UIKit 0x002d19bf _UIApplicationHandleEvent +
7672 13 GraphicsServices
0x03368822 PurpleEventCallback + 1550
14 CoreFoundation
0x02a69ff4
CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION
+ 52 15 CoreFoundation 0x029ca807 __CFRunLoopDoSource1 + 215
16 CoreFoundation
0x029c7a93 __CFRunLoopRun + 979 17
CoreFoundation
0x029c7350 CFRunLoopRunSpecific + 208
18 CoreFoundation
0x029c7271 CFRunLoopRunInMode + 97 19
UIKit
0x002c9c6d -[UIApplication _run] + 625
20 UIKit
0x002d5af2 UIApplicationMain + 1160
21 Vampire Quiz Final
0x00002144 main + 102 22 Vampire
Quiz Final 0x000020d5
start + 53 ) terminate called after
throwing an instance of 'NSException'
sharedlibrary apply-load-rules all
(gdb)
P.S. I am new to development on the iPhone
Thanks
This is my code :
#implementation Vampire_Quiz_FinalViewController
- (IBAction)V;
{
Vork *V = [[Vork alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:V animated:NO];
}
- (IBAction)A;
{
About *A = [[About alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:A animated:NO];
}
- (IBAction)I;
{
Instructions *I = [[Instructions alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:I animated:NO];
}
- (void)dealloc {
[super dealloc];
}
- (void)viewDidLoad {
adView = [[ADBannerView alloc] initWithFrame:CGRectZero];
adView.frame = CGRectOffset(adView.frame, 0, -50);
adView.requiredContentSizeIdentifiers = [NSSet setWithObject:ADBannerContentSizeIdentifier320x50];
adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifier320x50;
[self.view addSubview:adView];
adView.delegate=self;
self.bannerIsVisible=NO;
[super viewDidLoad];
}
- (void)bannerViewDidLoadAd:(ADBannerView *)banner
{
if (!self.bannerIsVisible)
{
[UIView beginAnimations:#"animateAdBannerOn" context:NULL];
// banner is invisible now and moved out of the screen on 50 px
banner.frame = CGRectOffset(banner.frame, 0, 50);
[UIView commitAnimations];
self.bannerIsVisible = YES;
}
}
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
if (self.bannerIsVisible)
{
[UIView beginAnimations:#"animateAdBannerOff" context:NULL];
// banner is visible and we move it out of the screen, due to connection issue
banner.frame = CGRectOffset(banner.frame, 0, -50);
[UIView commitAnimations];
self.bannerIsVisible = NO;
}
}
#end
How can I fix it???

you are using self.bannerIsVisible but I can't see neither a synthesize for this nor setters and getters. Did you made a property with bannerIsVisible in your .h file?
To resolve this crash you should define the property in you header and add a #synthesize statement in your implementation.
Maybe you should start with something more basic to get to know the fundamental things like properties, synthesizers, compiler warnings (there should be one), debugging, and so on.
I don't want to be rude, but you won't learn much by using copied code you don't understand.

unrecognized selector sent to instance: this means the method for that class is not found. Check the class implementation.

Related

iOS5 to iOS4 crash - ViewControllers

Currently I am trying to make my app available for iOS4, to increase the number of people we can reach.
We have moved away from StoryBoard and are now using .xib files instead.
Right now, the only thing that is stopping this is this error:
2012-09-14 18:32:42.705 CrunchCalculator[7037:11303] -[CategoryViewController presentViewController:animated:completion:]: unrecognized selector sent to instance 0x6b42230
2012-09-14 18:32:42.707 CrunchCalculator[7037:11303] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[CategoryViewController presentViewController:animated:completion:]: unrecognized selector sent to instance 0x6b42230'
*** Call stack at first throw:
(
0 CoreFoundation 0x013625a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x00ef1313 objc_exception_throw + 44
2 CoreFoundation 0x013640bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x012d3966 ___forwarding___ + 966
4 CoreFoundation 0x012d3522 _CF_forwarding_prep_0 + 50
5 CrunchCalculator 0x0002e560 +[OpenCalcViewController openCalcView:fromViewController:] + 8256
6 CrunchCalculator 0x0002fe0a -[CategoryViewController openCalc:] + 106
7 UIKit 0x002554fd -[UIApplication sendAction:to:from:forEvent:] + 119
8 UIKit 0x002e5799 -[UIControl sendAction:to:forEvent:] + 67
9 UIKit 0x002e7c2b -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
10 UIKit 0x002e67d8 -[UIControl touchesEnded:withEvent:] + 458
11 UIKit 0x004e84de _UIGestureRecognizerSortAndSendDelayedTouches + 3609
12 UIKit 0x004e8c53 _UIGestureRecognizerUpdateObserver + 927
13 CoreFoundation 0x0134389b __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 27
14 CoreFoundation 0x012d86e7 __CFRunLoopDoObservers + 295
15 CoreFoundation 0x012a11d7 __CFRunLoopRun + 1575
16 CoreFoundation 0x012a0840 CFRunLoopRunSpecific + 208
17 CoreFoundation 0x012a0761 CFRunLoopRunInMode + 97
18 GraphicsServices 0x014b61c4 GSEventRunModal + 217
19 GraphicsServices 0x014b6289 GSEventRun + 115
20 UIKit 0x00263c93 UIApplicationMain + 1160
21 CrunchCalculator 0x0000276a main + 170
22 CrunchCalculator 0x000026b5 start + 53
)
terminate called throwing an exception(lldb)
Usually I use this to open another view:
UIViewController *controller;
controller = [[CategoryViewController alloc]initWithNibName:#"CategoryViewController" bundle:nil];
controller.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:controller animated:YES];
[controller release];
But in this case I call a function from a different file (for efficiency) using this code:
#import "AllofTheFiles.h"
+ (void)openCalcView: (NSString *)nameOfView fromViewController:(UIViewController *)controller {
NSUserDefaults *saveSpot = [NSUserDefaults standardUserDefaults];
UIViewController *modalController;
if ([nameOfView isEqualToString:#"Tax"]) {
modalController= [[TAXViewController alloc]initWithNibName:#"TAXViewController" bundle:nil];
}else if ([nameOfView isEqualToString:#"Rent"]){
modalController= [[RENTViewController alloc]initWithNibName:#"RENTViewController" bundle:nil];
} //... cut other else if's to save space
modalController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[controller presentViewController:modalController animated:YES completion:nil];
[modalController release];
}
How can I fix this? Thanks in advance!
presentViewController:animated:completion: is available on iOS5 and above only, hence you get that crash.
Change the last part to:
modalController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
//do we support the new way of presenting a modal viewController?
if ([controller respondsToSelector:#selector(presentViewController:animated:completion:)])
{ //yes->so do it!
[controller presentViewController:modalController animated:YES completion:NULL];
}
else
{ //nope->we seem to be running on something prior to iOS5, do it the old way!
[controller presentModalViewController:modalController animated:YES];
}
[modalController release];
This will first check if the new way of presenting a viewController is supported. For making sure that this works fine in the future, as presentModalViewController: is marked as being deprecated, we only use that option if the new way is not available.
You may need to present a navcontroller, and/or use presentModalViewController, try the following:
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:modalController];
navController.modalPresentationStyle = UIModalPresentationPageSheet;
navController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[controller presentModalViewController:navController animated:YES completion:nil];
[modalController release];
[navController release];
The Till's solution is far the best.
But if, like me, you have numbers of present/DismissModalViewController: calls in your code, and doesn't want to duplicate the respondsToSelector test and is deprecated warnings over and over, just make UIViewController addition:
#implementation UIViewController (iOS4Compatibility)
- (void)presentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag {
if([self respondsToSelector:#selector(presentViewController:animated:completion:)])
[self presentViewController:viewControllerToPresent animated:flag completion:nil];
else
[self presentModalViewController:viewControllerToPresent animated:flag];
}
- (void)dismissViewControllerAnimated:(BOOL)flag {
if([self respondsToSelector:#selector(dismissViewControllerAnimated:completion:)])
[self dismissViewControllerAnimated:flag completion:nil];
else
[self dismissModalViewControllerAnimated:flag];
}
#end

UIWebView load crash [__NSCFDictionary _isChargeEnabled]

I use UIWebView to load this site http://www.xiami.com/song/1024665
sometimes my app crashes if I touch the view or play the audio in this site and sometimes it does not, why?
is it because html5? how to solve?
other website is no problem.
crash log is
* -[MPTransportButton _isChargeEnabled]: message sent to deallocated instance 0x20aa58d0
any help is much appreciated
---update---
I create a new view-base project, the code in ViewController is as following
This time, the crash log is
2011-08-16 18:11:25.450 WebTest[1291:707] -[__NSCFDictionary _isChargeEnabled]: unrecognized selector sent to instance 0x1ede0a10
2011-08-16 18:11:25.462 WebTest[1291:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary _isChargeEnabled]: unrecognized selector sent to instance 0x1ede0a10'
*** Call stack at first throw:
(
0 CoreFoundation 0x30ea764f __exceptionPreprocess + 114
1 libobjc.A.dylib 0x349c2c5d objc_exception_throw + 24
2 CoreFoundation 0x30eab1bf -[NSObject(NSObject) doesNotRecognizeSelector:] + 102
3 CoreFoundation 0x30eaa649 ___forwarding___ + 508
4 CoreFoundation 0x30e21180 _CF_forwarding_prep_0 + 48
5 UIKit 0x30f232bd -[UIWindow warpPoint:] + 200
6 UIKit 0x30f0c1d5 _UIApplicationHandleEvent + 2404
7 GraphicsServices 0x30790e77 PurpleEventCallback + 666
8 CoreFoundation 0x30e7ea97 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 26
9 CoreFoundation 0x30e8083f __CFRunLoopDoSource1 + 166
10 CoreFoundation 0x30e8160d __CFRunLoopRun + 520
11 CoreFoundation 0x30e11ec3 CFRunLoopRunSpecific + 230
12 CoreFoundation 0x30e11dcb CFRunLoopRunInMode + 58
13 GraphicsServices 0x3079041f GSEventRunModal + 114
14 GraphicsServices 0x307904cb GSEventRun + 62
15 UIKit 0x30f37d69 -[UIApplication _run] + 404
16 UIKit 0x30f35807 UIApplicationMain + 670
17 WebTest 0x00013425 main + 48
18 WebTest 0x000133f0 start + 40
)
terminate called after throwing an instance of 'NSException'
the source code in the project, not use MPMoviePlayerController this time or something else
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [self init];
return self;
}
- (id)init
{
if (self = [super initWithNibName:nil bundle:nil])
{
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
UIWebView *web = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)];
[web loadRequest:[NSURLRequest requestWithURL:
[NSURL URLWithString:#"http://www.xiami.com/song/1024665"]]];
web.delegate = self;
[self.view addSubview:web];
[web release];
}
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
return YES;
}
- (void)webViewDidStartLoad:(UIWebView *)webView
{
}
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
//[webView stringByEvaluatingJavaScriptFromString:#"window.scrollTo(0, 10);"];
}
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
}
There's nothing wrong in code that you posted.
NSZombie says that there is a MPTransportButton somewhere in your code that was previously deallocated (released) and after that, somewhere else in your code, you want to do something with it.
I think that you do it in one of your UIWebView's delegate methods.
But... we need more code. Where do you alloc/init your MPMoviePlayerController? Or do you alloc/init a MPTransportButton?

Adwhirl integration problem in iphone

I have two controllers in my application navigation controller and tabbar controller. Navigation controller view does not implement adwhirl and tabbar controller all tabs all view has adwhirl implemented.
#interface myview : UIViewController {
AdWhirlView *awView;
}
#property (nonatomic, retain) AdWhirlView *awView;
#implementation myview
#synthesize awView;
- (UIViewController *)viewControllerForPresentingModalView {
return self;
}
- (NSString *)adWhirlApplicationKey {
return #"Mykey";
}
-(void) viewWillAppear:(BOOL)animated{
// code for Adwhirl banner
self.awView = [AdWhirlView requestAdWhirlViewWithDelegate:self];
[self.awView setFrame:CGRectMake(0, 318, 320, 50)];
[self.view addSubview:self.awView];
}
-(void) viewWillDisappear:(BOOL)animated{
[self.awView release];
}
I have write this code in each view in tabbar controller. Adwhirl is perfectly work when i shift navigation controller to tabbar controller. But application is crashed when i shift tabbar controller to navigation controller.
The crash error is as follow.
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFArray viewControllerForPresentingModalView]: unrecognized selector sent to instance 0xfd91600'
*** Call stack at first throw:
(
0 CoreFoundation 0x018525a9 __exceptionPreprocess + 185
1 libobjc.A.dylib 0x019a6313 objc_exception_throw + 44
2 CoreFoundation 0x018540bb -[NSObject(NSObject) doesNotRecognizeSelector:] + 187
3 CoreFoundation 0x017c3966 ___forwarding___ + 966
4 CoreFoundation 0x017c3522 _CF_forwarding_prep_0 + 50
5 IDogEvents 0x0002e30b -[AdWhirlAdapterGoogleAdMobAds getAd] + 2075
6 IDogEvents 0x00040154 -[AdWhirlView makeAdRequest:] + 1524
7 IDogEvents 0x0003f501 -[AdWhirlView buildPrioritizedAdNetCfgsAndMakeRequest] + 1569
8 IDogEvents 0x000402ef -[AdWhirlView timerRequestFreshAd] + 255
9 Foundation 0x0095b749 __NSFireTimer + 125
10 CoreFoundation 0x018338c3 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 19
11 CoreFoundation 0x01834e74 __CFRunLoopDoTimer + 1220
12 CoreFoundation 0x017912c9 __CFRunLoopRun + 1817
13 CoreFoundation 0x01790840 CFRunLoopRunSpecific + 208
14 CoreFoundation 0x01790761 CFRunLoopRunInMode + 97
15 GraphicsServices 0x01a8a1c4 GSEventRunModal + 217
16 GraphicsServices 0x01a8a289 GSEventRun + 115
17 UIKit 0x001cbc93 UIApplicationMain + 1160
18 IDogEvents 0x00002349 main + 121
19 IDogEvents 0x000022c5 start + 53
20 ??? 0x00000001 0x0 + 1
Please help me for this.Thanks in advance.
I got the solution.
I made common object for
AdWhirlView *awView;
in application delegate.
In every view i am using this object instead of self class object.
-(void) viewWillAppear:(BOOL)animated{
// code for Adwhirl banner
appDelegate.awView = [AdWhirlView requestAdWhirlViewWithDelegate:self];
[appDelegate.awView setFrame:CGRectMake(0, 318, 320, 50)];
[self.view addSubview:appDelegate.awView];
}
-(void) viewWillDisappear:(BOOL)animated{
[appDelegate.awView removeFromSuperview];
}
And in final view where i shift the controller.
-(void) viewWillDisappear:(BOOL)animated{
[appDelegate.awView removeFromSuperview];
[appDelegate.awView release];
}

How to debug iPhone app crash log. Crash only in App Store purchased version, not in development

I received the first crash report but I am not able to get what is the problem.
Fortunately, since this crash came from a colleague of mine, I can test the error directly on his iPhone and install a development version on his phone.
However, the strange thing is that when I install and run the development version on his device from my computer there is no crash; the crash appear only when the application is downloaded and installed from the App Store.
Until now I could not reproduce the error on any other device (the affected device is an iPhone 3G firmware 4.2.1 and all the operating system run very slowly).
The crash happen after that a row is selected from a UITableViewController (ItemsListTableViewController), at this point a detail view should appear, but the application crash during the construction of the detail view (ItemDetailViewController) in viewDidLoad.
In particular the problem seem to be localized within the class LocationPathView (a subview of ItemDetailViewController's view).
ItemDetailViewController is a subclass of UITableViewController and load its tableHeaderView from nib in viewDidLoad with:
[[NSBundle mainBundle] loadNibNamed:#"ItemDetailHeaderView" owner:self options:nil];
(LocationPathView is part of the tableHeaderView)
When the nib file is loaded, LocationPathView::awakeFromNib is called and then LocationPathView::layoutSubviews is called. The crash seem to be originated from layoutSubviews.
Within layoutSubviews I perform an animation:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.2];
Could this animation create for some reasons the crash on slow device? Is correct to animate within layoutSubviews?
I would be grateful for any help,
Marco
Date/Time: 2011-04-30 12:50:36.972 +0200
OS Version: iPhone OS 4.2.1 (8C148)
Report Version: 104
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x00000000, 0x00000000
Crashed Thread: 0
Thread 0 Crashed:
0 libSystem.B.dylib 0x35de3ad0 __kill + 8
1 libSystem.B.dylib 0x35de3abe kill + 4
2 libSystem.B.dylib 0x35de3ab2 raise + 10
3 libSystem.B.dylib 0x35dfad5e abort + 54
4 libstdc++.6.dylib 0x374f2a00 __gnu_cxx::__verbose_terminate_handler() + 588
5 libobjc.A.dylib 0x32d9d8d8 _objc_terminate + 160
6 libstdc++.6.dylib 0x374f0100 __cxxabiv1::__terminate(void (*)()) + 76
7 libstdc++.6.dylib 0x374f0178 std::terminate() + 16
8 libstdc++.6.dylib 0x374f02a0 __cxa_throw + 100
9 libobjc.A.dylib 0x32d9bf28 objc_exception_throw + 104
10 CoreFoundation 0x3759dabc +[NSException raise:format:arguments:] + 64
11 CoreFoundation 0x3759daf0 +[NSException raise:format:] + 24
12 QuartzCore 0x33d9409c CALayerSetPosition(CALayer*, CA::Vec2<double> const&, bool) + 180
13 QuartzCore 0x33d93fd8 -[CALayer setPosition:] + 40
14 QuartzCore 0x33d93efc -[CALayer setFrame:] + 444
15 UIKit 0x358d92c8 -[UIView(Geometry) setFrame:] + 248
16 UIKit 0x3592dde0 -[UIButton setFrame:] + 120
17 MyApp 0x0003432a -[LocationPathView layoutSubviews] (LocationPathView.m:101) <<<<<<<<<<<<<<<<<<<<<<<<<<<
18 UIKit 0x358ec704 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 32
19 CoreFoundation 0x37538f72 -[NSObject(NSObject) performSelector:withObject:] + 18
20 QuartzCore 0x33d9a128 -[CALayer layoutSublayers] + 176
21 QuartzCore 0x33d99db0 CALayerLayoutIfNeeded + 192
22 QuartzCore 0x33d99cd8 -[CALayer layoutIfNeeded] + 108
23 UIKit 0x3598ee38 -[UIView(Hierarchy) layoutIfNeeded] + 24
24 UIKit 0x359fbabc -[UIButton titleLabel] + 76
25 MyApp 0x0001fee8 -[ItemDetailViewController viewDidLoad] (ItemDetailViewController.m:148) <<<<<<<<<<<<<<<<<<<<<<<<<<<
26 UIKit 0x35926e58 -[UIViewController view] + 152
27 UIKit 0x35937f2c -[UIViewController contentScrollView] + 24
28 UIKit 0x35937d4c -[UINavigationController _computeAndApplyScrollContentInsetDeltaForViewController:] + 36
29 UIKit 0x35937bf8 -[UINavigationController _layoutViewController:] + 28
30 UIKit 0x35937474 -[UINavigationController _startTransition:fromViewController:toViewController:] + 336
31 UIKit 0x35937288 -[UINavigationController _startDeferredTransitionIfNeeded] + 256
32 UIKit 0x35926c44 -[UINavigationController pushViewController:transition:forceImmediate:] + 904
33 UIKit 0x359268a8 -[UINavigationController pushViewController:animated:] + 36
34 MyApp 0x00020a9a -[ItemsListTableViewController viewItemDetail:startEditable:] (ItemsListTableViewController.m:717)
35 MyApp 0x00022110 -[ItemsListTableViewController tableView:didSelectRowAtIndexPath:] (ItemsListTableViewController.m:241) <<<<<<<<<<<<<<<<<<<<<<<<<<<
36 UIKit 0x3595bf4c -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 884
37 UIKit 0x35a5da9c -[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 196
38 Foundation 0x351724d4 __NSFireDelayedPerform + 360
39 CoreFoundation 0x375522fe __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 10
40 CoreFoundation 0x37551cd2 __CFRunLoopDoTimer + 982
41 CoreFoundation 0x37521a8a __CFRunLoopRun + 1178
42 CoreFoundation 0x37521504 CFRunLoopRunSpecific + 220
43 CoreFoundation 0x37521412 CFRunLoopRunInMode + 54
44 GraphicsServices 0x33e76d1c GSEventRunModal + 188
45 UIKit 0x3591d574 -[UIApplication _run] + 580
46 UIKit 0x3591a550 UIApplicationMain + 964
47 MyApp 0x00002fce main (main.m:14)
48 MyApp 0x00002f98 0x1000 + 8088
ItemsListTableViewController.m:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
Item *item = [self.fetchedResultsController objectAtIndexPath:indexPath];
[self viewItemDetail:item startEditable:NO]; <<<<<<<<<<<<<<<<<<<
}
- (void)viewItemDetail:(Item *)item startEditable:(BOOL)editable {
ItemDetailViewController *controller = [[ItemDetailViewController alloc] initWithStyle:UITableViewStyleGrouped showItem:item inItemsList:[self.fetchedResultsController fetchedObjects]];
if (editable)
controller.editing = YES;
[self.navigationController pushViewController:controller animated:YES]; <<<<<<<<<<<<<<<<<<<
[controller release];
}
ItemDetailViewController.m:
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationItem.title = NSLocalizedString(#"Item details", #"Item details");
self.navigationItem.rightBarButtonItem = self.editButtonItem;
self.view.backgroundColor = [UIColor groupTableViewBackgroundColor];
// Configure the tableview
self.tableView.sectionFooterHeight = 5.0f;
self.tableView.allowsSelectionDuringEditing = YES;
// Create and set the tableview header
if (headerView == nil) {
[[NSBundle mainBundle] loadNibNamed:#"ItemDetailHeaderView" owner:self options:nil]; <<<<<<<<<<<<<<<<<<<<<<<<<<<
// Item title button
itemTitleButton.titleLabel.adjustsFontSizeToFitWidth = YES;
itemTitleButton.titleLabel.minimumFontSize = 11.0f;
[itemTitleButton setImageEdgeInsets:UIEdgeInsetsMake(0.0f, itemTitleButton.bounds.size.width-29.0f, 0.0f, 0.0f)];
[itemTitleButton setTitleEdgeInsets:UIEdgeInsetsMake(0.0f, 0.0f, 0.0f, 24.0f)];
UIImage *normalImage = [[UIImage imageNamed:#"objectNameHighlighedButton.png"] stretchableImageWithLeftCapWidth:11 topCapHeight:0];
[self.itemTitleButton setBackgroundImage:normalImage forState:UIControlStateHighlighted];
[pathView addTarget:self action:#selector(moveButtonTouchUp:) forControlEvents:UILocationPathViewMoveControlEvent];
// Check if the item's path should be recalculated
if (pathView.pathList == nil) {
pathView.pathList = pathNames;
}
self.tableView.tableHeaderView = headerView;
// Save initial header height so that it can be restore navigating between items with different flags count
tableHeaderFrameHeight = headerView.frame.size.height;
}
// Enable the UIToolbar at the bottom of the view controller and create its buttons
[self.navigationController setToolbarHidden:NO animated:YES];
self.navigationController.toolbar.barStyle = UIBarStyleBlack;
self.navigationController.toolbar.translucent = YES;
// [omitted part]: create toolbar items …
// Restore editing status if the view was unloaded
if (viewUnloaded && self.editing) {
viewUnloaded = NO;
// this will force setEditing:YES to be called on all tableView's subviews! (categorySectionHeaderView...)
[self.tableView setEditing:YES];
// ...not for tableheader!
editableImageView.editing = YES;
pathView.editing = YES;
}
// Recreate item flags
CGRect headerFrame = headerView.frame;
for (FlaggedItem *flagObject in self.itemBookmarkRibbons) {
headerFrame.size.height += ITEM_SHEET_FLAG_BUTTON_HEIGHT + 8.0f;
headerView.frame = headerFrame;
UIButton *bookmarkRibbon = [self createBookmarkRibbon:flagObject];
bookmarkRibbon.frame = CGRectMake(0.0f, headerFrame.size.height-ITEM_SHEET_FLAG_BUTTON_HEIGHT-8.0f,
headerFrame.size.width, ITEM_SHEET_FLAG_BUTTON_HEIGHT);
[headerView addSubview:bookmarkRibbon];
[headerView sendSubviewToBack:bookmarkRibbon];
}
// Update the table header view height
self.tableView.tableHeaderView = headerView;
}
LocationPathView.m:
- (void)awakeFromNib {
[super awakeFromNib];
UIColor *color = [[UIColor alloc] initWithWhite:0.0f alpha:0.0f];
self.backgroundColor = color;
[color release];
[self sendSubviewToBack:backgroundView];
// create imageview rounded rect
CALayer *l = [backgroundView layer];
[l setMasksToBounds:YES];
[l setCornerRadius:10.0];
[l setBorderWidth:2.0];
UIColor *borderColor = [[UIColor alloc] initWithWhite:0.65 alpha:1.0];
[l setBorderColor:[borderColor CGColor]];
[borderColor release];
expanded = NO;
buttons = [[NSMutableArray alloc] initWithCapacity:2];
[buttons addObject:[self createButtonOfType:PVButtonTypeStart]];
[buttons addObject:[self createButtonOfType:PVButtonTypeEnd]];
}
- (void)layoutSubviews {
#define MOVE_BUTTON_WIDTH 90.0f
#define STANDARD_BUTTON_HEIGHT 22.0f
[super layoutSubviews];
CGRect contentRect = self.frame;
if (CGRectIsEmpty(contentRect))
return;
if ([buttons count] != [pathList count] && [pathList count] > 0) {
[self prepareButtons];
}
[UIView beginAnimations:nil context:nil]; <<<<<<<<<<<<<<<<<<<
[UIView setAnimationDuration:0.2];
CGFloat x = 0.0f, y = 0.0f;
CGFloat availableHSpace = 0.0f;
UIButton *button;
for (NSUInteger i=0; i<[self.buttons count]; i++) {
button = [buttons objectAtIndex:i];
if (self.isExpanded == NO && i > 0 && i <= [self.buttons count]-2)
// hide all middle buttons
button.alpha = 0.0f;
else {
button.alpha = 1.0f;
NSString *title = [pathList objectAtIndex:i];
CGSize size = [title sizeWithFont:button.titleLabel.font];
CGFloat buttonWidth = size.width + 36.0f;
// check if the button width is greater than available space, if yes set the button width equal to the available space.
// The available space is reduced in editing move to make room for the move button.
if (self.editing && moveButton)
availableHSpace = contentRect.size.width - MOVE_BUTTON_WIDTH - 3.0f - 10.0f; // 10.0=space from move button
else
availableHSpace = contentRect.size.width;
if (x + buttonWidth > availableHSpace)
buttonWidth = availableHSpace - x;
button.frame = CGRectMake(x, y, buttonWidth, STANDARD_BUTTON_HEIGHT);
[button setTitle:title forState:UIControlStateNormal];
y += STANDARD_BUTTON_HEIGHT + 3.0f; // vertical distance between buttons
}
if (self.isExpanded)
x += 14.0f; // indentation
}
// setup cyan background
backgroundView.alpha = (self.isExpanded ? 0.80f : 0.0f);
CGRect backgroundViewFrame = backgroundView.frame;
if (self.isExpanded) {
// 10.0 = 5.0=y gap between backgroundView and self + 5.0=distance between edge
backgroundViewFrame.size.height = button.frame.origin.y + button.frame.size.height + 12.0f;
}
else
backgroundViewFrame.size.height = self.frame.size.height;
backgroundView.frame = backgroundViewFrame;
[UIView commitAnimations];
// set moveButton position and make it visible (put it out of animation block to avoid frame changing animation,
// fade animation already set from caller)
if (self.editing && moveButton) {
moveButton.frame = CGRectMake(0.0f, 0.0f, MOVE_BUTTON_WIDTH, STANDARD_BUTTON_HEIGHT*2 + 3.0f); // 3.0=vertical space between buttons
moveButton.center = CGPointMake(contentRect.size.width - MOVE_BUTTON_WIDTH/2 - 3.0f, contentRect.size.height/2);
moveButton.hidden = NO;
}
}
Being an error only the app-store version makes me suspicious of a project or target setting used to build the submission binary.
Are you using a project configuration to build the submission binary? If so, the first thing I would look for is a C macro is defined incorrectly for a release version. Or perhaps it is correct at the project-level, but incorrect at the target-level. Perhaps the end of your animation block is not correctly signalled?
Building an ad-hoc version of the app with the exact same settings as your app store version would be a good test. (Code signing would be the only difference.) Delete the old app from the device and deploy it the hard way through iTunes to be sure.
It might be your animation block blocking the main transition running behind. Try to avoid these kind of situation. For example popAviewController and just after push another this kind of situation lead to crash because you are doing another transition before previous one finished. Hope you understand.

Crash presenting modal view controller

I have this crash. It is similar to other threads, but not the same.
I would like to show a modal view controller first the user goes to a specific view controller. Following the hints, I do that on - (void) viewDidAppear:(BOOL)animated, and apply a delay as I saw it's recommended.
- (void) viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[self performSelector:#selector(presentMyModal) withObject:nil afterDelay:1];
}
- (void) presentModal{
ModalViewController *modal = [[[ModalViewController alloc] init] autorelease];
[self presentModalViewController:modal animated:YES];
}
Afterwards, ramdomly It crashes. I get this message in console:
<Warning>: *** Assertion failure in -[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:], /SourceCache/UIKit/UIKit-1447.6.4/UIWindowController.m:186
Thu Feb 3 10:00:44 unknown MyApp[1830] <Error>: *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Attempting to begin a modal transition from <UINavigationController: 0x454260> to <ModalViewController: 0x47af00> while a transition is already in progress. Wait for viewDidAppear/viewDidDisappear to know the current transition has completed'
*** Call stack at first throw:
(
0 CoreFoundation 0x3759dc7b __exceptionPreprocess + 114
1 libobjc.A.dylib 0x32d9bee8 objc_exception_throw + 40
2 CoreFoundation 0x3759dac3 +[NSException raise:format:arguments:] + 70
3 Foundation 0x351a3e73 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 62
4 UIKit 0x359e92a8 -[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:] + 208
5 UIKit 0x359e8c98 -[UIViewController presentModalViewController:withTransition:] + 2792
6 UIKit 0x35a7b51c -[UIViewController _tryRecursivelyPresentModalViewController:withTransition:] + 116
7 UIKit 0x359e84c0 -[UIViewController presentModalViewController:withTransition:] + 784
8 UIKit 0x359e8060 -[UIViewController presentModalViewController:animated:] + 96
9 MyApp 0x0005d57f -[MyAppViewController presentMyModal] + 58
10 Foundation 0x351724db __NSFireDelayedPerform + 366
11 CoreFoundation 0x37552305 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 16
12 CoreFoundation 0x37551cd9 __CFRunLoopDoTimer + 988
13 CoreFoundation 0x37521a91 __CFRunLoopRun + 1184
14 CoreFoundation 0x3752150b CFRunLoopRunSpecific + 226
15 CoreFoundation 0x37521419 CFRunLoopRunInMode + 60
16 GraphicsServices 0x33e76d24 GSEventRunModal + 196
17 UIKit 0x3591d57c -[UIApplication _run] + 588
18 UIKit 0x3591a558 UIApplicationMain + 972
19 MyApp 0x0000e75f main + 50
20 MyApp 0x0000e6e8 start + 52
As you can see, I wait until view is appeared. Is this maybe an OS bug? It seems like it tries to present recursively other modal view controllers, provoquing crashes.
Thanks a lot.
Apart from me being picky in the comment, I thought I could as well help with this one as well. I think you need to search for the culprit somewhere else. I created a new project and a view controller with this snippet:
#import "VC1.h"
#implementation VC1
- (void) viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[self performSelector:#selector(presentModal) withObject:nil afterDelay:1.0];
}
- (void)presentModal {
static int colorChooser = 0;
VC1 *vc1 = [[[VC1 alloc] init] autorelease];
switch (colorChooser%2) {
case 0:
vc1.view.backgroundColor = [UIColor whiteColor];
break;
default:
vc1.view.backgroundColor = [UIColor blackColor];
break;
}
colorChooser++;
[self presentModalViewController:vc1 animated:YES];
}
#end
And it works flawlessly after being pushed on the navigation controller. It is recursively alternating between black and white views, tested both in the sim and on a 3G device.
Maybe you are doing some other view transitions due to some notifications or other asynchronic means? Either way you would need to share more of your code for anyone to tell where the problem is.
Our preferred solution is to use -[UIViewController presentViewController:animated:completion:] and do whatever the next action is (eg presenting another VC) in the completion block.
For example:
[self presentViewController:yourViewController animated:YES completion:^{
[yourViewController presentMyModal];
}];
This method was introduced in iOS 5.0.