Xcode 5中的横向和纵向自定义button

我已经在Xcode 5创build自定义button。在纵向视图黄色button将不得不显示和横向模式蓝色button将不得不display.my代码如下:

-(BOOL)shouldAutorotate { UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; if (orientation == UIInterfaceOrientationPortrait) { [self addYellowBtn1]; } else if(orientation == UIInterfaceOrientationLandscapeRight) { [self addLightBlueBtn2]; } return YES; } 

当我运行这个应用程序,在第一个肖像视图显示黄色button.but当我改变成风景两个button都显示。任何人都可以帮助我吗?

假设这是你的Portrait方法function

 -(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]; }