I know, if I need help I should go post on some apple board... but it's information overflow.... and I am not 100% sure it's related to the extension.
Here's the problem
I am creating/using an extension to open the MFMailComposeViewController.
Now, I figured out how to open it and force it to landscape, but the problem is when I close the email it, my app flips upside down. (landscape left when it was landscape right before, or vice versa)
My app is set to force landscape left and right... and the mail controller does open in landscape... but it's either upside down (landscape right, when the app is left, or vice versa) or when it closes, it flips the application the other way.
Has anyone encountered anything like this and ideas on how to fix it?
My app publish settings, I set to landscape, auto-orient is set to false and it's full screen,
However, on start up in code... I am setting stage.autoOrients = true and then using the CustomOrientation.as to control the rotation (to force landscape only)
in my extension, I am showing the MFMailComposeViewController in the
[[[[UIApplication sharedApplication] keyWindow] rootViewcontroller] presentModalViewcontroller:mailCompser animated:NO];
and mailCompser is a subclassed MFMailComposeViewcontroller object and I have set it's override to this:
@implementation MailCompose
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) toInterfaceOrientation {
return (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
When I launch my app, it starts
stage.orientation = rotatedRight
I then launch my extension and the email page for ios appears, in the correct orientation.... if I rotate the device, both the email and the app rotate to rotatedRight or rotatedLeft correctly.
I then click Cancel, delete draft
The email window disappears, but now my screen is landscape left.... if I wiggle the device, the sensor picks it up and then rotates the app back right, but this is a major problem.
I am thinking it has something to do with the rootViewController orienatation, but I don't know enough about objC and xcode to know what to do.
I have tried googling and searching will little to no luck... but then, the answer could be staring at me and I would have missed it as I am an obj c noob.
Anyone know how I can fix this?
Hi Dave:
I doubt if there is correct fix for this. This causes because of the how AIR runtime behaves and handles the rootController which hosts the application(Stage).
But I have a workaround (Drawbacks are small flicker and may not work(work incorrectly) if autoOrients is false.)
Workaround:
When modelViewController(mailComposer) is being dissmissed do [[NSNotificationCenter defaultCenter] postNotificationName:UIDeviceOrientationDidChangeNotification object:nil];
this should bring your app to correct orientation.
Hope this helps.
Regards,
Saumitra
I can live with a flicker... but I tried adding that line and now my app will not compile.
I am getting
ld: absolute addressing (perhaps -mdynamic-no-pic) used in -[MailComposerHelper mailComposeController:didFinishWithResult:error:] from C:\ ... \MailExtension.a(MailComposerHelper.o) not allowed in slidable image. Use '-read_only_relocs suppress' to enable text relocs Compilation failed while executing : ld64
Now, I did quite a bit of googling and can't find the solution.
Things I did find and tried:
Setting "Enable Linking with shared Libraries" to yes - didn't work
Setting "Other Linker Flags" to -read_only_relocs suppress this also didn't work.
I comment out [[NSNotificationCenter defaultCenter] postNotificationName:UIDeviceOrientationDidChangeNotification object:nil]; without making ANY other changes and ADT compiled the app without any issues.
obviously, I am missing something simple... any thoughts?
Well, it is a dirty fix, but I managed to get it working....
in my extension, I added events to tell me before the window opens and after it has been opened, as well as before it closes and after it closes.
Then in my main app, I set stage.autoOrients to false before it opens and closes and then set it back to true after it has opened and closed... this pretty much stops it from orienting during the show and hide of the composer, but allowing it to change while it is open and after it closes...
not exactly what I was looking for, but it seems to work.
the only thing I had to do was add a [[NSRunLoop currentRunLoop] runUntilDate:[NSDate date]]; after each event dispatch so the events would trigger before the rest of the xcode would actually fire.
Hello Dave,
I tried to follow your solution and in some manner it did help me to restrict the game screen to be in landscape mode only after mail is closed, but what happens is, game screen gets rotated by 180 degree after the mail is closed... i.e. if mail is closed in landscape left, game screen goes to landscape right...
Even though I tried to set Orientation in DID Hide mail composer event then in subsequent calls to mail client it shows 180 degree rotated, not sure what is happening.. Do you have some thoughts to share which I can try?
BTW you can get rid of this "ld: absolute addressing (perhaps -mdynamic-no-pic) used in -[MailComposerHelper mailComposeController:didFinishWithResult:error:] from C:\ ... \MailExtension.a(MailComposerHelper.o) not allowed in slidable image. Use '-read_only_relocs suppress' to enable text relocs Compilation failed while executing : ld64"
just by adding UIKit framework in your target. Xcode->Target Project Setting->General->Add framework... (as UIDeviceOrientationDidChangeNotification is defined in UIKit's UIDevice class)...
Best Wishes,
Sanniv
Hi:
Even though I tried to set Orientation in DID Hide mail composer event then in subsequent calls to mail client it shows 180 degree rotated, not sure what is happening.. Do you have some thoughts to share which I can try?
Did you try posting a notification(As described in thread above) instead setting orientation?
Hi,
I had the same problem and found the following workaround: apart from overriding MFMailComposeViewController's shouldAutorotateToInterfaceOrientation, I also added implementations for
_preferredInterfaceOrientationGivenCurrentOrientation
and
_isSupportedInterfaceOrientation
in a category of UIViewController in the native code.
Then, in the Actionscript code, added an event listener for StageOrientationEvent.ORIENTATION_CHANGING (with high priority and use_capture = true) in Actionscript to prevent resizing of the stage, which can occur even if the orientation doesn’t change.
This fixed it for me, but, as it messes with UIViewController, it makes it tricky to have views which have different orientation behaviour (if you want one view to be able to rotate in all directions, but others only to support Landscape, for example).
I've posted details and example code here: http://blog.diadraw.com/native-extensions-for-mobile-air-apps-getting- round-the-orientation-issue/
North America
Europe, Middle East and Africa
Asia Pacific