When clicks on done button application crashes and gives message that program received signal SIGABRT.
In the ModalViewController.h delegated protocol and method
@protocol ModalViewDelegate <NSObject>
-(void) dismissModalView:(UIViewController *) viewController;
@end
@interface Infoviewcontroller : UIViewController <ModalViewDelegate>
{
id<ModalViewDelegate> dismissDelegate;
}
@property (nonatomic, retain) id<ModalViewDelegate> dismissDelegate;
@end
In modalviewcontroller. m file
@synthesize dismissDelegate;
-(void) dismissModalView:(UIViewController *) viewController;
{
[self dismissModalViewControllerAnimated:YES];
}
@end
In done button definition
UIButton* backButton = [UIButton buttonWithType:101];
[backButton addTarget:self action:@selector(dismissView:) forControlEvents:UIControlEventTouchUpInside];
[backButton setTitle:@"Done" forState:UIControlStateNormal];
// create button item
UIBarButtonItem* backItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
// add the button to navigation bar
self.navigationItem.leftBarButtonItem = backItem;
[backItem release];
-(void) dismissView: (id)sender
{
[UIViewController dismissDelegate];
}
When clicks on done button application crashes and gives message that program received signal SIGABRT. So i think i m doing something wrong in dismissView method of done button that is why it gives message that UIViewController dismissDelegate unrecognized selector
Help will be appreciated.
Thanks
You’re calling a class method on UIViewController which doesn’t exist (dismissDelegate – which you’ve defined as a property of Infoviewcontroller).
I think you’re somewhat confused with the use of the ModalViewDelegate, let me try to explain…
In the Apple View Controller Programming Guide, the recommendation is that the ViewController that presents the modal controller is responsible for dismissing it. Therefore you need a way for the modal controller to talk to the presenting controller.
So… Your presenting controller should conform to your ModalViewDelegate protocol ( not your modal controller as you have here).
When you present the modal view controller, you set its delegate to self (self being the presenting view controller).
Your dismissView method should then be:
Actually, you probably don’t even need to pass the UIViewController parameter to the delegate as you won’t end up using it.
Finally, your dismissDelegate property really should not be retained, it should be assigned instead (otherwise you end up with a circular retain relationship).