Custom buttons in landscape and portrait in Xcode 5

流过昼夜 提交于 2019-12-13 01:28:00

问题


i have created custom buttons in Xcode 5.In portrait view yellow button will have to display and in landscape mode blue button will have to display.my code is below:

-(BOOL)shouldAutorotate {

   UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];

            if (orientation == UIInterfaceOrientationPortrait) {

                [self addYellowBtn1];


            }
            else if(orientation == UIInterfaceOrientationLandscapeRight)
            {

               [self addLightBlueBtn2];

            }

            return YES;
        }

when i run this app,at first portrait view displays the yellow button.but when i change into landscape both buttons were displayed.can anyone help me?


回答1:


assume that this is your Portrait method functionalities

-(void)addYellowBtn1:(id)sender

{
     // here hide the blue button
     [bluebuttonname setHidden:YES];

    // enable the yellow button

    [yellowbuttonname setHidden:NO];

 }

in LandscapeRight

-(void) addLightBlueBtn2:(id)sender

{
     // here hide the yellow button 

   [yellowbuttonname setHidden:YES];

    // enable the blue button

        [bluebuttonname setHidden:NO];

 }


来源:https://stackoverflow.com/questions/26708422/custom-buttons-in-landscape-and-portrait-in-xcode-5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!