views:

23

answers:

2

In xCode, writing an iPhone app, should I NOT put code after/while flipping a view?

I seem to get random crashes....

{
    FlipsideViewController *controller = [[FlipsideViewController alloc] initWithNibName:@"FlipsideView" bundle:nil];
    controller.delegate = self;

    controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    [self presentModalViewController:controller animated:YES];

    [controller release];

    ////////////////// Should I not put any code here???
    // Code that takes 0.0001 secs to run?   Or 0.1 secs?   Or 1-2 secs?
}

or when flipping back:

{
    [self.delegate flipsideViewControllerDidFinish:self];   

    ////////////////// Should I not put any code here???
    // Code that takes 0.0001 secs to run?   Or 0.1 secs?   Or 1-2 secs?

}
A: 

If you are consirned that the code might effect the graphoc performance of the app, you can use threading. There is a very good guide about that in the documentation. Look it up.

But I think it won't effect the performance. You code will be executed after the flipping. Although when it comes to graphich you can never be completely sure.

tadej5553
A: 

Like @tadej5553 said your code there will be executed after the flipping is complete. But bare in mind that if you put code that takes 2 seconds to execute then the flip will complete but the UI will be blocked and unresponsive for those 2 seconds. So that should be done in another thread, or at least use a delegate pattern. If you are talking less then 0.1 seconds then it would be ok in my opinion to run it there. Any more and a quick user will notice the lag. If your view can't be used until the operation is complete then I would still do the code in another thread but then just show a UIAlertView with a UISpinner and no buttons, so the user can't dismiss it. Only when your code is finished will it dismiss the UIAlertView

jamone