UIViewController didRotateFromInterfaceOrientation аргумент fromInterfaceOrientation, возвращающий значение мусора - PullRequest
0 голосов
/ 13 июля 2011

При повороте iPhone вверх ногами во время моих тестов я обнаружил, что, хотя вызывается

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation

, параметр UIInterfaceOrientation, передаваемый в качестве аргумента, является значением мусора (т. Е. Случайное целое число, определенное вдокументация Apple вместо константы UIInterfaceOrientation).Как мне сделать так, чтобы оно возвращало действительное значение?

1 Ответ

3 голосов
/ 13 июля 2011

Не возвращается значение мусора.

Сравните значение со следующими константами:

UIInterfaceOrientationLandscapeLeft;
UIInterfaceOrientationLandscapeRight;
UIInterfaceOrientationPortrait;
UIInterfaceOrientationPortraitUpsideDown;

т.

if (fromInterfaceOrientation == UIInterfaceOrientationPortrait) {
     NSLog(@"PORTRAIT");
}

Или используйте следующие макросы BOOL:

UIInterfaceOrientationIsLandscape(fromInterfaceOrientation);
UIInterfaceOrientationIsPortrait(fromInterfaceOrientation);

т.

if (UIInterfaceOrientationIsPortrait(fromInterfaceOrientation)) {
    NSLog(@"PORTRAIT");
}
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...