iOS: Device orientation on load

前端 未结 16 1830
遥遥无期
遥遥无期 2020-11-28 23:45

It seems that when my app loads, it does not know its current orientation:

UIInterfaceOrientation orientation = [[UIDevice currentDevice] orientation];
if (o         


        
16条回答
  •  有刺的猬
    2020-11-29 00:25

    Tried all and no good results. So what I did, as I'm on an ipad, was to leave all the work to the splitViewController methods to invalidate the barButton:

    For portrait:

    - (void)splitViewController:(UISplitViewController *)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem *)barButtonItem forPopoverController: (UIPopoverController *)pc { NSlog(@"portrait");}
    

    For landscape:

    - (void)splitViewController:(UISplitViewController *)svc willShowViewController:(UIViewController *)aViewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem{ NSlog(@"landscape");}
    

    this always works on load.

提交回复
热议问题