When i click on done button which has code
UIBarButtonItem * button = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone
target:self
action:@selector(dismissView:)] autorelease];
self.navigationItem.rightBarButtonItem=UIBarButtonSystemItemDone;
[[self navigationItem] setRightBarButtonItem:button];
[button release];
-(void)dismissView: (id)sender
{
[self.navigationController popToRootViewControllerAnimated:YES];
}
application crashes and gives message Program received signal EXC_BAD_ACCESS
Any ideas what is wrong.
Thanks for help.
This line is entirely wrong:
Remove it. You are setting the
rightBarButtonItemright after that and also, you can’t set therightBarButtonItemtoUIBarButtonSystemItemDone– that just doesn’t make any sense at all.Oh and you’re overreleasing
button. Remove the[button release];as well.