单击uiBarButton时,会发生NSInvalidArgumentException,我的代码如下:
-(IBAction) sendSms:(id)sender {
MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init];
picker.messageComposeDelegate = self;
picker.recipients = [NSArray arrayWithObject:@"1234567890"];
picker.body = @"Help me";
[self presentModalViewController:picker animated:YES];
[picker release];
}
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result {
NSString *message = [[NSString alloc] init];
switch(result) {
case MessageComposeResultCancelled:
message = [[NSString alloc] initWithFormat:@"Result: cancelled"];
NSLog(@"Result: canceled");
break;
case MessageComposeResultSent:
message = [[NSString alloc] initWithFormat:@"Result: sent"];
NSLog(@"Result: sent");
break;
case MessageComposeResultFailed:
message = [[NSString alloc] initWithFormat:@"Result: failed"];
NSLog(@"Result: failed");
break;
default:
message = [[NSString alloc] initWithFormat:@"Result: not sent"];
NSLog(@"Result: not sent");
break;
}
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Message Status" message:message delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];
[message release];
[self dismissModalViewControllerAnimated:YES];
}
错误器显示目标上的nil模态视图控制器。请告诉我我的错误,我已将uibarButton的操作与接口构建器中的IBAaction正确链接。请尽快帮助我。提前谢谢。