我有一個View Controller,它顯示一個表視圖。該VC調用另一個VC以顯示發短信視圖給用戶,這個短信代碼VC是:呈現視圖在MFMessageComposeViewController被呈現然後被駁回後沒有正確顯示
- (void) sendSMSWithBody: (NSString*) body andRecipients: (NSArray*) recipients
{
MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init];
if ([MFMessageComposeViewController canSendText])
{
controller.messageComposeDelegate = self;
controller.body = body;
controller.recipients = recipients;
[[UIApplication sharedApplication].delegate.window.rootViewController addChildViewController:self];
[self presentModalViewController:controller animated:YES];
}
}
- (void) messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result
{
[self dismissModalViewControllerAnimated:YES];
[[UIApplication sharedApplication].delegate.window.rootViewController removeFromParentViewController];
}
(我知道調用sharedApplication有點哈克,但它現在就足夠了。 RootViewController的是具有設置爲表視圖控制器其根控制器)
我從表VC調用SMS VC像這樣一個UINavigationController:
- (void) viewDidAppear:(BOOL)animated
{
static BOOL presentedSMSVC = NO;
if (!presentedSMSVC)
{
SendSMSController *sendSMS = [[SendSMSController alloc] init];
[sendSMS sendSMSWithBody:@"body"
andRecipients:[NSArray arrayWithObject:@"123456789"]];
presentedRegisterVC = YES;
}
}
的問題是,在用戶發送SMS表格視圖單元格不顯示。
我想也許我需要刷新視圖/表,所以我添加了從第二個VC協議回調到第一個,當用戶發送SMS時調用,然後在回調調用[self.tableView reloadData]但它沒有任何區別。
所以我擺脫了中介類和編輯表視圖中直接顯示短信看法是這樣的:
- (void) viewDidAppear:(BOOL)animated
{
static BOOL presentedRegisterVC = NO;
if (!presentedRegisterVC)
{
MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init];
if ([MFMessageComposeViewController canSendText])
{
controller.messageComposeDelegate = self;
controller.body = @"body";
controller.recipients = [NSArray arrayWithObject:@"12345678"];
[self presentModalViewController:controller animated:NO];
}
}
}
- (void) messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result
{
[self dismissModalViewControllerAnimated:NO];
}
但現在MFMessageComposeViewController不解僱(雖然messageComposeViewController:didFinishWithResult:不會被調用)
這兩種方法有什麼問題?感謝
我也嘗試改變目前和解僱行[self.navigationController presentModalViewController和解僱]但它仍然不會解僱第二個更新的變體。 – Gruntcakes 2012-03-16 20:06:49