2012-03-14 30 views
0

我有一个应用程序,它里面有一个sendInAppSMS操作。它带来了一个预先输入正文的窗口。问题是按取消按钮不起作用。如果我按发送它发送消息,但不关闭窗口。所以我必须彻底关闭应用程序才能摆脱它。关闭短信inapp窗口iOS 5.1

有人在那里谁可能跑到这之前?试图在这里搜索,但无法找到解决方案..

干杯!

这是我的代码看起来像:

-(IBAction) sendInAppSMS:(id) sender 
{ 
    MFMessageComposeViewController *controller = [[[MFMessageComposeViewController alloc] init] autorelease]; 
    if([MFMessageComposeViewController canSendText]) 
    { 
     CLLocation *location=[self findCurrentLocation]; 
     CLLocationCoordinate2D coordinae=[location coordinate]; 
     controller.body =[[NSString alloc] initWithFormat:@" Alarm!, call the senders number with latitude:%f longitude:%f",coordinae.latitude,coordinae.longitude]; ; 
     controller.recipients = [NSArray arrayWithObjects:@"phonenumber1", @"phonenumber2", nil]; 
     [self presentModalViewController:controller animated:YES]; 
    } 
} 

我边学边做,所以我不期望的答案,但如果你觉得助阵,做到哪里我把它在此代码?

回答

0

您是否设置并实现了MFMessageComposeViewControllerDelegate?试试这个

- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result{ 
    [controller dismissModalViewControllerAnimated:YES]; 
} 

编辑:
要设置委托:

MFMessageComposeViewController *myComposer = [MFMessageComposeViewController alloc] init]; 
myComposer.messageComposeDelegate = self; 
+0

对不起,我是这样一个的n00b,我不指望一个答案,但无法找出把那个代码(请记住,我是一名设计师,刚刚开始学习编程应用程序,并且仍在阅读我的第一本书):P – Marcus 2012-03-14 11:15:33

+0

解决了它!谢谢!有正确的代码,只是缺少controller.messageComposeDelegate = self;现在效果很棒! – Marcus 2012-03-14 11:32:59