On 8 Aug 2014, at 10:57, Roland King <[email protected]> wrote:

> 
>> On 8 Aug 2014, at 11:50 am, Gerriet M. Denkmann <[email protected]> wrote:
>> 
>> Master-Detail app on iOS. Universal, Xcode (Targets, General) allows all 
>> orientations.
>> 
>> Problem: on iPhone the DetailView does not make sense in landscape (iPad is 
>> fine with landscape).
>> 
>> Fix1: added supportedInterfaceOrientations to DetailViewController, but this 
>> did never get called.
>> "When the user changes the device orientation, the system calls this method 
>> on the root view controller or the topmost presented view controller that 
>> fills the window."
>> Probably my DetailViewController is not the root view controller. Ok.
>> 
>> Fix2: added supportedInterfaceOrientations to MasterViewController; this 
>> gets called occasionally and iPhone returns 0x6 (should mean both portraits, 
>> no landscape) and shouldAutorotate is YES (I checked).
>> 
>> The layout is:
>> Window → UINavigationController → MasterViewController
>> 
>> But the silly phone ignores the return value and displays in landscape (why 
>> does it ask, if it is going to ignore my answer?).
>> 
>> Device 7.1.2; Xcode 6 beta 5; SDK latest.
>> 
> 
> 
> Why not just put them in the Deployment Info in the General tab so they go in 
> the plist file like you’ve been meant to since .. not sure .. iOS6 perhaps.

My Info.plist contains:

Supported interface orientations =
<array>
        <string>UIInterfaceOrientationPortrait</string>
        <string>UIInterfaceOrientationLandscapeLeft</string>
        <string>UIInterfaceOrientationLandscapeRight</string>
        <string>UIInterfaceOrientationPortraitUpsideDown</string>
</array>

as it should, because on iPad all orientations are allowed.

>  It’s the nav controller gets to choose, that’s the rootviewcontroller. 

Yes. But this thing I have not created (nor subclassed). Probably created by 
some storyboard magic.

Do you mean I have to subclass it to MyRootNavigationController, which only 
implements supportedInterfaceOrientations?
No. Better give it a delegate, which implements 
navigationControllerSupportedInterfaceOrientations:

Easier said than done though.
The Main.storyboard contains a "Navigation Controller Scene", but no 
AppDelegate. How should I set this to be the delegate also of the 
NavigationController?
Creating a class MyNavigationDelegate just for one method seems a bit silly.


Just did:

- (BOOL)application:(UIApplication *)application 
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
        NSArray *allWindows = application.windows;
        if ( [ allWindows count ] != 1 )        //      warn
        {
                NSLog(@"%s Warning: have %lu windows (should have 
1)",__FUNCTION__,[ allWindows count ]);
        };
        
        UIWindow *someRandomWindow = allWindows.firstObject;
        
        UINavigationController *rootViewController = 
(UINavigationController*)someRandomWindow.rootViewController;
        if ( ![ rootViewController isKindOfClass: [ UINavigationController 
class ] ] )  //      error
        {
                NSLog(@"%s Error bad class rootViewController 
%@",__FUNCTION__,rootViewController);
                return YES;
        };
        
        if ( rootViewController.delegate != nil )       //      error
        {
                NSLog(@"%s Error rootViewController already has delegate 
%@",__FUNCTION__,rootViewController.delegate );
                return YES;
        };
        
        rootViewController.delegate = self;
        return YES;
}

This seems to work, but it really looks like a very bad hack.
There sure must be a better solution.

Kind regards,

Gerriet.


_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to