开发者

App crashes on the iPhone when trying to open a particular modal view on every alternate build-run

I have a moda开发者_如何学JAVAl view controller which calls another modal view controller in viewDidLoad based on an if condition.

The weird problem i'm facing is, the first time i compile the app and open the 1st modal view controller, it works fine and it goes on to show the 2nd view controller. Now, if i stop the app execution and rebuild & run the app, the app crashes (freezes with only the home button working) when i open the 1st modal view.

This is the error i get:

Detected an attempt to call a symbol in system libraries that is not present on the iPhone:
_Unwind_Resume called from function -[NSArray makeObjectsPerformSelector:] in image CoreFoundation.
2010-09-23 20:19:56.526 MySuperDuperApp[6117:207] CoreAnimation: ignoring exception: [<TwitterLogin 0x7484dc0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key actionButton.

TwitterLogin is the name of the 2nd modal view controller which fails to display.

I tried putting NSLogs to check where exactly it is crashing.

    //... part of the method which is called in  
    // viewDidAppear of first modal view controller.
    - (void)login {
    NSLog(@"Begin TwitterBasicVC login");       
    loginPopup = [[TwitterLogin alloc] init];
    loginPopup.oAuth = oAuth;
    loginPopup.viewDelegate = self;
    loginPopup.interfaceDelegate = self;

    // Show Login screen.
    loginPopup.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    NSLog(@"presenting loginPopup modalView");
    [self presentModalViewController:loginPopup animated:YES];  
    [loginPopup release];
    NSLog(@"End TwitterBasicVC login");

    //... viewDidLoad of second modal view controller.
    - (void)viewDidLoad {
     NSLog(@"Begin TwitterLogin viewDidLoad");
         [super viewDidLoad];
     queue = [[NSOperationQueue alloc] init];
     ...

The 'presenting loginPopup modalView' message is printed, however the 'Begin TwitterLogin viewDidLoad' message is not printed. I don't know why it is crashing between the modal view presentation and viewDidLoad.

The weirder thing is that this happens every alternate time i build/run the app. (I have tried deleting the app and building it but it still occurs)

EDIT: I have added the first few lines of the login method where twitterLogin is alloc-inited. I have also tried calling the method with performSelector:withObject:afterDelay with values 0.0 and 1.0 and the problem still exists.

EDIT 2: I did a clean build each time i try to install the app on the iPhone/Simulator (after deleting the app from the device/simulator). The app seems to be working fine with this method. Can I assume that it is safe to upload the app on the app store?

Any suggestions on how I should proceed in debugging will greatly help me :)

Thanks


I guess it's not recommended to modally display two controllers within the same loop iteration.

Try to present the second controller after some small delay (use blocks if on iOS4+ or create a method and call it via performSelector:withObject:afterDelay:0.1f).

Anyway, I can't explain the weirdness of this happening every second time. Do you by accident flip some setting during each execution (for example isLoggedIn = !isLoggedIn; and persisting it in NSUserDefaults).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜