0

I using xcode 4.2 new ARC feature to develop a new app,but i got a crash problem with pushViewController to present a new view.The following is my code:

QuestionVew *view = [[QuestionVew alloc] initWithStyle : UITableViewStyleGrouped];
[self.navigationController pushViewController : view animated : YES];

The view level is :

BookView -> ChapterView -> SectionView -> QuestionVew.

All of them are UITableViewController.

When I switch those views very quickly,the crash was happened! And the error message is :

-[UIViewAnimationState sendDelegateAnimationDidStop:finished:]:
message sent to deallocated instance 0x22b28f90

What happened for this situation?How do I solve it?

Thanks!

----------New Edit--------

After edit, I got problem :

[UIViewAnimationState release]: message sent to deallocated instance 0x3ade8f90

 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    // do something
    QuestionVew *view = [[QuestionVew alloc] initWithStyle : UITableViewStyleGrouped];
    [self performSelector : @selector(showChildView:) withObject:view afterDelay:0.1];
 }

 - (void) showChildView : (UITableViewController *) aView {
    [self.navigationController pushViewController : aView animated : YES];
 }
[UIViewAnimationState release]: message sent to deallocated instance 0x3ade8f90

And,I can't release any object because the ARC not allowed.

Halle
  • 3,584
  • 1
  • 37
  • 53
Tericky Shih
  • 1,670
  • 3
  • 16
  • 22

5 Answers5

0

tell me one thing are you even coming back that is poping the view like from question to book or someotherview?? if this is the case then it will definitely crash becoz all the view controllers are in a stack and when you simulataneously pop and push it misses the reference of the controller and it crashes .I suppose you should create an array of view controller and pop to particular array according to your need.

NSArray *array = [self.navigationController viewControllers];
    [self.navigationController popToViewController:[array objectAtIndex:1] animated:YES];
Kasaname
  • 1,491
  • 11
  • 15
0

Have a look at this question. If you are presenting modal views quickly one after another, you should add a tiny delay between the two. So, replace your code

[self.navigationController pushViewController : view animated : YES];

with

 [self performSelector:@selector(presentModal) withObject:nil afterDelay:0.1];

and add method

- (void) presentModal{
    [self presentModalViewController:view animated:YES];  
}
Community
  • 1
  • 1
Maggie
  • 7,823
  • 7
  • 45
  • 66
0

In the viewDidUnload method, write the following code.

self.tableView.delegate = nil;
self.tableView.dataSource = nil;
halfer
  • 19,824
  • 17
  • 99
  • 186
Satya
  • 3,320
  • 1
  • 20
  • 19
0

Try this way

[view setModalPresentationStyle:UIModalPresentationFullScreen];

[self presentModalViewController:view animated:YES];

after reading your comment. This is the solution I can provide you

try this:

UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController: view];

[view setModalPresentationStyle:UIModalPresentationFullScreen];

[self presentModalViewController:navController animated:YES];

//navController.navigationBarHidden = YES;

[navController release];

I use this logical to maintain separate stack for different navigation controllers. And it works for me.

Anand
  • 2,086
  • 2
  • 26
  • 44
  • Thanks for your reply,but I need keep navigation bar on screen.[presentModalViewController] made navigation bar disappear. – Tericky Shih Aug 19 '11 at 06:42
-1

you have released some object which is using furthur.If you comment it ,then it may not crash.Focus on the release .

Tendulkar
  • 5,550
  • 2
  • 27
  • 53