问题
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