2013-02-25 90 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的代碼計算出來。