-(void)search:(id)sender {
if (([[UIDevice currentDevice]orientation]==UIDeviceOrientationLandscapeLeft)||([[UIDevice currentDevice]orientation]==UIDeviceOrientationLandscapeRight)) {
[self landscapeTextField];
}
else if (([[UIDevice currentDevice] orientation] == UIDeviceOrientationPortrait) || ([[UIDevice currentDevice] orientation] == UIDeviceOrientationPortraitUpsideDown)) {
[self portraitSearchTextField];
}
}
我在点击应用程序按钮时调用此函数。
当我处于纵向模式时[self portraitSearchTextField]
未调用
我检查了调试模式。
当我将else if
替换为else [self portraitSearchTextField];
其工作
但在应用程序加载时我的当前设备处于纵向模式...为什么不执行此条件。任何人都可以帮助我。
@thanks提前。
答案 0 :(得分:0)
试试这个:
-(void)search:(id)sender {
if (([[UIDevice currentDevice]orientation]==UIDeviceOrientationLandscapeLeft)||([[UIDevice currentDevice]orientation]==UIDeviceOrientationLandscapeRight)) {
[self landscapeTextField];
}
else {
if (([[UIDevice currentDevice] orientation] == UIDeviceOrientationPortrait) || ([[UIDevice currentDevice] orientation] == UIDeviceOrientationPortraitUpsideDown)) {
[self portraitSearchTextField];
}
}
}