2013-02-25 1 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.