Modal View In TabBar iPhone App
I have TabBar app th开发者_开发百科at loads several .xib files. In one of the views I am trying to load a modal view to compose an email in the app over the the view. I am using
- (IBAction)buttonPressed {
MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init];
[controller setSubject:@"Email Subject"];
[controller setMessageBody:@"Email Messgae" isHTML:NO];
[self presentModalViewController:controller animated:YES];
[controller release];
}
I it has worked with several new view-based apps I built but not with the TabBar app. Whenever I try to run the action, nothing happens. Is there something I'm missing or am I going about it the wrong way? Thanks! If the answer is simple, sorry, I'm still learning!
EDIT: Additional info: rebuilt it and it now crashes when the action is run.
What is "self"? Is it the UITabBarController? If not, it should be. Or it could be a UINavigationController within the tab bar, which is probably better. Either way, it needs to be one of those to show a modal view.
You should also check whether it's linked up correctly in Interface Builder to set the selector on the button to call this function. I usually use TouchUpInside. Check to make sure whichever you are using is linked to your buttonPressed
function.
Tell me if that helps.
2 things
[1] NSLOG a message in the above and see if its actually linked (the log message should appear in the console)
[2] If it crashes, paste in a crash log
Hilton
精彩评论