2014-11-03 72 views
1

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

-(BOOL)shouldAutorotate { 

    UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; 

      if (orientation == UIInterfaceOrientationPortrait) { 

       [self addYellowBtn1]; 


      } 
      else if(orientation == UIInterfaceOrientationLandscapeRight) 
      { 

       [self addLightBlueBtn2]; 

      } 

      return YES; 
     } 

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

+0

您需要删除或隐藏其存在于potraite模式的按钮。 – Balu 2014-11-03 05:43:31

+0

您的编码是好​​的,U需要修改的东西 – 2014-11-03 05:47:45

+0

如何隐藏黄色按钮,在景观 – 2014-11-03 05:49:33

回答

0

以为这是您的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]; 

} 
+0

initally隐藏自己的蓝色按钮,在viewDidLoad中,如果u需要我希望用U任何援助 – 2014-11-03 05:53:57

+0

有一个幸福的一天,我的朋友, – 2014-11-03 05:57:50