0

我正在从我的视图控制器以编程方式发送短信,但现在它向我显示状态栏和垂直黑线

我的代码:

- (IBAction)SendTextBtnTapped:(id)sender {
    [self sendSMS:@"Body of SMS..." recipientList:[NSArray arrayWithObjects: nil]];
}


- (void)sendSMS:(NSString *)bodyOfMessage recipientList:(NSArray *)recipients
{
    MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init];
    if([MFMessageComposeViewController canSendText])
    {
        controller.body = bodyOfMessage;    
        controller.recipients = recipients;
        controller.messageComposeDelegate = self;
        [self presentModalViewController:controller animated:YES];
    }    
}

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

    if (result == MessageComposeResultCancelled)
        NSLog(@"Message cancelled");
    else if (result == MessageComposeResultSent)
        NSLog(@"Message sent");  
    else 
        NSLog(@"Message failed");
}

在此处输入图像描述

4

2 回答 2

1

只需添加这一行

controller.wantsFullScreenLayout = YES;

在当前 MessageViewController 之后添加此行,如下所示。

[self presentModalViewController:controller animated:YES];
[[UIApplication sharedApplication] setStatusBarHidden:YES];

或者对于整个视图控制器,使用下面的登录viewWillAppear:粘贴此代码..

[[UIApplication sharedApplication] setStatusBarHidden:YES animated:YES];
于 2012-12-03T11:01:54.343 回答
1

我认为您可以使用WantsFullScreenLayout

MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init];
if([MFMessageComposeViewController canSendText])
{
    controller.body = bodyOfMessage;    
    controller.recipients = recipients;
    controller.messageComposeDelegate = self;
    controller.wantsFullScreenLayout = YES;  //<== add this
    [self presentModalViewController:controller animated:YES];
} 
于 2012-12-03T11:02:19.053 回答