2011-12-19 69 views
0

我在我的Xcode項目中創建了一個具有2個文本字段的表單,用戶可以在其中插入其當前地址和目標。當我點擊第二個文本字段中的發送返回鍵時,郵件撰寫控制器顯示正常。Xcode MFMessageComposeViewController狀態欄和文本字段

但問題是,消息的主體不是從文本字段和消息中「拖動」值。所以我希望我的文本字段中的值具有消息正文。 問題在哪裏?

-(IBAction)btnSendSms:(id)sender { 


    [sender resignFirstResponder]; 
    [[UIApplication sharedApplication ] setStatusBarStyle:UIStatusBarStyleBlackOpaque]; 
    MFMessageComposeViewController *controller = [[[MFMessageComposeViewController alloc] init] autorelease]; 
    if ([MFMessageComposeViewController canSendText]) { 

     controller.body = @"My body text %@: " , textField1.text , textField2.text; 

     controller.recipients = [NSArray arrayWithObjects:@"011888",nil]; 
     controller.messageComposeDelegate = self; 
     controller.navigationBar.tintColor = [UIColor blackColor]; 

     [self presentModalViewController:controller animated:YES]; 

回答

0

你應該糾正機體字符串:

controller.body = [NSString stringWithFormat:@"My body text %@: %@", textField1.text, textField2.text ]; 
+0

感謝,它工作正常.. – dsafa 2011-12-19 14:28:09