Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot show modal ViewController in iOS7

Tags:

ios

ios7

I tried to show system defined viewcontrollers (MFMailComposeViewController, TWTweetComposeViewController,etc..) as a modal view.

But these viewcontrollers dosn't appear in iOS 7(these run in iOS5,iOS6).

Viewcontrollers created by me appear in iOS7(ex.HogeViewController).

I don't call presentViewController:animated:completion at viewDidLoad or viewWillAppear.

Does anybody have an idea?

Console logs:

init Error Domain=NSCocoaErrorDomain Code=4097 "The operation couldn’t be completed. (Cocoa error 4097.)"

or

_serviceViewControllerReady:error: Error Domain=NSCocoaErrorDomain Code=4097 "The operation couldn’t be completed. (Cocoa error 4097.)"

or

Unbalanced calls to begin/end appearance transitions for .

TWTweetComposeViewController(doesn't appear)

TWTweetComposeViewController *viewController = [[TWTweetComposeViewController alloc]init];
viewController.completionHandler = ^(TWTweetComposeViewControllerResult result){
    NSLog(@"Result : %d",result);
};
[self presentViewController:viewController animated:YES completion:NULL];

Log

Result : 0

MFMailComposeViewController(appears a moment and dismiss soon)

- (void)send:(NSString*)email{
    if ([MFMailComposeViewController canSendMail]) {
        MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
        picker.mailComposeDelegate = self;

        NSArray *toRecipients = @[email];
        [picker setToRecipients:toRecipients];

        [picker setSubject:@"Subject"];
        [picker setMessageBody:@"Body" isHTML:NO];
        [self.navigationController presentViewController:picker animated:YES completion:NULL];
    }
}

- (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error {
    [self dismissViewControllerAnimated:YES completion:^{
        NSLog(@"error:%@,result:%d",error.description,result);
    }];
}

Log

_serviceViewControllerReady:error: Error Domain=NSCocoaErrorDomain Code=4097 "The operation couldn’t be completed. (Cocoa error 4097.)" Unbalanced calls to begin/end appearance transitions for . error:(null),result:0

like image 830
Yu Tamura Avatar asked Sep 24 '13 10:09

Yu Tamura


2 Answers

Turns out the issue only shows up when customizing UIBarButtons. If we use the following in our 32-bit app running on iPhone 5s, we have the problem:

[[UIBarButtonItem appearance] setTitlePositionAdjustment:UIOffsetMake(0, 1.0)
                                           forBarMetrics:UIBarMetricsDefault];

Leaving out that line works around the problem. We have filed a radar.

like image 142
flo_muc Avatar answered Sep 23 '22 06:09

flo_muc


This is an issue when you do not compile for 64bit (arm64) in your project settings. Though this may not always be an option for some people because currently Google Analytics does not support the 64bit devices.

like image 29
Brandyn Brosemer Avatar answered Sep 24 '22 06:09

Brandyn Brosemer