2 bluetooth99 bluetooth99 于 2013.06.13 14:44 提问

在WeeApp中的横屏模式

需要横屏模式下,在widget中心做一个标签。

[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
if (([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeLeft) ||
    ([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeRight))
{
     d = 516; //my var to change the Position (The Value is just a test)
}

不知道为什么没实现。

1个回答

xinyoulingxi1_tong
xinyoulingxi1_tong   2013.06.13 16:50
已采纳

AppController定义这个方法:

- (void)willAnimateRotationToInterfaceOrientation:(int)arg1

然后检测方向:

if (UIInterfaceOrientationIsLandscape(arg1)) {
    // you're in landscape mode
    float screenWidth = [UIScreen mainScreen].bounds.size.height;
}
else {
    // you're in portrait mode
    float screenWidth = [UIScreen mainScreen].bounds.size.width;
}
Csdn user default icon
上传中...
上传图片
插入图片