单击 uiBarButton 时出错
单击 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 正确链接。请尽快帮助我。提前致谢。
On clicking the uiBarButton,NSInvalidArgumentException occurs and my code is below:
-(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];
}
the errorr shows that nil modal view controller on target. Please tell me my error, i have linked the action of that uibarButton properly with IBAaction in interface builder. Please help me asap. Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请检查此链接。
您的 MFMessageComposeViewController 对象(选择器)未正确初始化。
此处列出了无法初始化的条件。
Please check this link.
Your MFMessageComposeViewController object (picker) is not initialized properly.
The conditions that it would fail to initialize are listed there.