在Xcode中横向和纵向的自定义按钮5(Custom buttons in landscape an

2019-10-21 05:25发布

我已经建立在Xcode 5.In纵向视图黄色按钮自定义按钮将具有显示和在横向模式下的蓝色按钮将不得不display.my代码如下:

-(BOOL)shouldAutorotate {

   UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];

            if (orientation == UIInterfaceOrientationPortrait) {

                [self addYellowBtn1];


            }
            else if(orientation == UIInterfaceOrientationLandscapeRight)
            {

               [self addLightBlueBtn2];

            }

            return YES;
        }

当我运行这个程序,在第一纵向视图显示黄色button.but当我变成景观的两个按钮分别displayed.can谁能帮助我?

Answer 1:

假设这是你的Portrait方法的功能

-(void)addYellowBtn1:(id)sender

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

    // enable the yellow button

    [yellowbuttonname setHidden:NO];

 }

LandscapeRight

-(void) addLightBlueBtn2:(id)sender

{
     // here hide the yellow button 

   [yellowbuttonname setHidden:YES];

    // enable the blue button

        [bluebuttonname setHidden:NO];

 }


文章来源: Custom buttons in landscape and portrait in Xcode 5