views:

27

answers:

1

I have an opengl game for iPhone/iPad (universal). I added the ability to send an SMS message using MFMessageComposeViewController. Testing in a real iPhone. The SMS composer sheet animates up over my view, I can send the message or not, didFinishWithResult gets called, and when I [self dismissModalViewControllerAnimated:YES] it goes away and my glview is asked to layoutSubviews. At that point the backing width and height are now zero, and my frame buffer status check fails. The self.layer.frame.size.width is still 320x460.

- (void)layoutSubviews
{
    NSLog(@"layoutSubviews");
    [EAGLContext setCurrentContext:context];
    [self destroyFramebuffer];
    [self createFramebuffer];
    [self drawView];
}

I do have a UIViewController for my glView which is where I handle orientation changes for the iPad and where I also put the MFMessage stuff. (Technically I guess since it's universal there are two different viewControllers, two app Delegates and two nibs - but I'm working in the iPhone set here because the iPad doesn't sms). On the iPad layoutSubviews gets called when the orientation changes, we destroy and re-create the framebuffers at the new size and everything is fine. But here when coming back from sending the SMS it fails on the re-creating. I can post the code if necessary but its the standard creating framebuffer code.

Another important point is that I'm using a notification to tell the method inside of the viewcontroller to start the sms stuff. I tried just having those methods in my glview and making it the MFMessageComposeViewControllerDelegate but then I was getting errors because glview is a UIView and not a UIViewController.

Any ideas?

A: 

Not sure if it's a bug or what the deal is but I had to create another view, make self.view = anotherView, retain my glview and removeFromSuperview before presenting the modal. And then wait to bring my glview back until everything was animated back into place.

If anyone wants more info please let me know.

Edit with actual answer:

It is a bug and as I suspected it has to do with the status bar. My app has no status bar. But when I

    [self presentModalViewController:controller animated:YES];

the SMS message composer view does show the iphone status bar. When it is dismissed and my app showed through underneath my framebuffer was getting borked. I had figured out a weird work around of switching views to protect my glview framebuffer - but then figured out to add a statusBarHidden before the dismiss and all is well now. Here's the dismiss code:

    - (void)messageComposeViewController:(MFMessageComposeViewController *)controller 
             didFinishWithResult:(MessageComposeResult)result {

      // Notifies users about errors associated with the interface
      switch (result)
      { ... }
      [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
      [self dismissModalViewControllerAnimated:YES];
    }
badweasel
Apple has asked me to send it in to them as a bug report. In the mean time my work around is working fine now.
badweasel