Двигатель, над которым я работал некоторое время и поставлял игры, теперь запускает мой текущий проект с ног на голову, и сразу же поворачивает UIView так, как это должно быть.Я создаю интерфейс с кодом, и это примерно так:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
...
CGRect screenBounds = [[UIScreen mainScreen] applicationFrame];
CGRect windowBounds = screenBounds;
windowBounds.origin.y = 0.0;
UIWindow* win = [[UIWindow alloc] initWithFrame:windowBounds];
win.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
UIMyView* view = [[UIMyView alloc] initWithFrame:screenBounds];
UIMyViewController* controller = [[UIMyViewController alloc] init];
controller.view = view;
view.multipleTouchEnabled = true;
view.windowWrapper = this;
view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[win addSubview:view];
...
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation;
{
s32 validOrientations = ((cViewMM*)(self.view)).windowWrapper->GetValidOrientations();
if (toInterfaceOrientation == UIInterfaceOrientationPortrait && (validOrientations & 0x01))
return true;
if (toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown && (validOrientations & 0x02))
return true;
if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft && (validOrientations & 0x04))
return true;
if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight && (validOrientations & 0x08))
return true;
return false;
}
Проблема возникает, только если я хочу запустить приложение в UIInterfaceOrientationLandscapeLeft.Отладка через приложение выглядит так, когда я пытаюсь добавить свой вид к окну внутренне, shouldAutorotateToInterfaceOrientation: вызывается несколько раз.Сначала с UIInterfaceOrientationPortrait, который возвращает false, затем UIInterfaceOrientationLandscapeRight, который возвращает true (поскольку это действительная ориентация), а затем UIInterfaceOrientationLandscapeLeft, который также возвращает true (так как это действительная ориентация и текущая ориентация устройства).
Oh и, чтобы быть болееКонкретно это происходит только на iPhone, а не на iPad.Они используют один и тот же код для настройки этого представления.
Что я делаю не так?
- РЕДАКТИРОВАТЬ -
ОК Я был не прав относительно выполнения shouldAutorotateToInterfaceOrientation: itвыполняется 3 раза с запросом UIInterfaceOrientationPortrait, 2 раза для UIInterfaceOrientationLandscapeLeft, затем один раз для UIInterfaceOrientationLandscapeRight и еще раз один раз для UIInterfaceOrientationLandscapeLeft.
GameCenter уже инициализируется на этом этапе, и, поскольку он выдвигает некоторый дополнительный интерфейс, я подумал, что это может быть, но это не так.