MFMessageComposeViewController中的收件人栏位置不正确

时间:2018-10-05 09:13:51

标签: ios objective-c uinavigationbar

我在我的应用程序中使用MFMessageComposeViewController发送短信。但是,我发现收件人栏位置不正确,收件人列表将隐藏在导航栏后面。如何正确制作?请帮忙。谢谢。

以下是我的示例代码:-

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
  MFMessageComposeViewController *messageVC = [[MFMessageComposeViewController alloc] init];
        messageVC.edgesForExtendedLayout = UIRectEdgeNone;

        if([_strProductUrl length] >0)
        {
            messageVC.body = _strProductUrl;
            [[NSNotificationCenter defaultCenter]postNotificationName:@"smsProductDetails" object:nil];

        }

       if([_strEventUrl length] >0)
        {
            messageVC.body = _strEventUrl;
            [[NSNotificationCenter defaultCenter]postNotificationName:@"smsEventDetails" object:nil];

        }
        messageVC.messageComposeDelegate = self;
        messageVC.delegate = self;

        //Set Custom Navigation Bar in SMS
        UINavigationItem *navigationItem = [[[messageVC viewControllers] lastObject] navigationItem];
        [navigationItem setTitle:@"New Message"];


        UIButton* ButSign = [[UIButton alloc] initWithFrame:CGRectMake(0,0, 40,20)];
        [ButSign setTitle:@"Cancel" forState:UIControlStateNormal];
        [ButSign setTitleColor:ThemeDarkBlueColor forState:UIControlStateNormal];
        ButSign.titleLabel.font = [UIFont systemFontOfSize:15.0];

        [ButSign addTarget:self action:@selector(cancelButtonClick) forControlEvents:UIControlEventTouchUpInside];
        navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:ButSign];

        if(![MFMessageComposeViewController canSendText])
        {
            SCLAlertView *alert = [[SCLAlertView alloc] init];
            alert.customViewColor = ThemeRedColor;
            [alert showError:self title:@"Error" subTitle:@"Your device doesn't support SMS"
            closeButtonTitle:@"Done" duration:0.0f ];
            return;
        }

        [self presentViewController:messageVC animated:NO completion:NULL];
}

//Share link to SMS
- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result
{
            NSLog(@"some code here");
}

enter image description here

0 个答案:

没有答案