2013-02-25 89 views
1

我知道iOS中有很多关于UIDeviceOrientation的问题,但没有人为我工作。我想在以风景模式为中心的Widget中制作标签。WeeApp的风景模式

[[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) 
} 

而且这并没有为我工作由于某种原因...

在此先感谢。

回答

0

我刚刚计算出了我今天的小工具。定义方法

- (void)willAnimateRotationToInterfaceOrientation:(int)arg1 

为您的AppController。在内部,检查哪个方向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; 
} 

你可以看到我的文件here我实现这一点。我通过查看WeeFacebook的代码计算出来。