loongman
loongman

Reputation: 92

First table cell is covered by contact input field on MFMessageComposeViewController

- (void)sendSmsWithSubject:(NSString *)subject andBody:(NSString *)body {
    MFMessageComposeViewController *smsCompose = [[MFMessageComposeViewController alloc] init];

    smsCompose.subject = subject;
    smsCompose.body = body;
    smsCompose.messageComposeDelegate = self;

    [self presentViewController:smsCompose animated:YES completion:nil];
}

As you can see on the attached screenshot, the first table cell "TestA" is covered by the text field on MFMessageComposeViewController. Above are the code snippet.

It seems like a bug on MFMessageComposeViewController, however, after doing some searches on stackoverflow, etc, there is no record for that "issue". Is there anything wrong or missed on my code? Thanks in advance for your help.

Notes: This UI issue is not happen on iOS10 devices.

enter image description here

Upvotes: 0

Views: 29

Answers (1)

loongman
loongman

Reputation: 92

Finally figured out that, in my case, the issue was caused by:

[[UIScrollView appearance] setContentInsetAdjustmentBehavior:UIScrollViewContentInsetAdjustmentNever];

As fix/workaround:

- (void)sendSmsWithSubject:(NSString *)subject andBody:(NSString *)body {
    [[UIScrollView appearance] setContentInsetAdjustmentBehavior:UIScrollViewContentInsetAdjustmentAutomatic];

    MFMessageComposeViewController *smsCompose = [[MFMessageComposeViewController alloc] init];

    smsCompose.subject = subject;
    smsCompose.body = body;
    smsCompose.messageComposeDelegate = self;

    [self presentViewController:smsCompose animated:YES completion:nil];
}

- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result {
    // Disable contentInsetAdjustmentBehavior when leave MFMessageComposeViewController.
    [[UIScrollView appearance] setContentInsetAdjustmentBehavior:UIScrollViewContentInsetAdjustmentNever];

    [self dismissViewControllerAnimated:YES completion:nil];
}

Hope this is helpful to someone else who meet the same issue. Thanks.

Upvotes: 0

Related Questions