Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
353 views
in Technique[技术] by (71.8m points)

ios7 - Recipients field of MFMessageComposeViewController doesn't show in iOS 7

The code below works fine in iOS 5/6. In iOS 7, it looks like this (red oval for emphasis).

enter image description here

Code:

if ([MFMessageComposeViewController canSendText]) {
    self.messageComposer = [MFMessageComposeViewController new];
    self.messageComposer.recipients = @[number];
    self.messageComposer.messageComposeDelegate = self;
    [self presentViewController:self.messageComposer
                       animated:YES
                     completion:nil];
}

Question: This is simple code. Is there some other external property, perhaps of the presenting view controller, that is affecting this? Anyone have a fix or workaround?

thanks.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I've found that the MFMessageComposeViewController's recipient field seems to take some of it's appearance from the UINavigationBar appearance proxy in iOS7. To work around this, I've done the following in my apps:

  1. Create an empty custom UINavigationController subclass, which doesn't override any of UINavigationController's methods.

  2. Use this custom UINavigationController subclass as a marker for any navigation controllers that I want to have custom appearance, by setting the custom class on the identity inspector in IB:

    enter image description here

  3. In my app delegate, set up the appearance of navigation bars like this:

     [[UINavigationBar appearanceWhenContainedIn:[MyCustomNavigationController class], nil] ...];
    

This ensures that I get the navigation bar appearance I want in the controllers I want to customize, but preserves the standard navigation bar (and related) appearance in other controllers (like MFMessageComposeViewController). Here's a screenshot; note the standard appearance of MFMessageComposeViewController, with the custom navigation bar appearance on the popover in the background:

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...