У меня есть простое приложение Master-Detail с MasterViewController и DetailViewController.Внутри DetailViewController я реализовал следующий код, чтобы при повороте вида мои две кнопки были расположены правильно.
- (void)willAnimateRotationToInterfaceOrientation:
(UIInterfaceOrientation)toInterfaceOrientation
duration:(NSTimeInterval)duration
{
if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft)
{ firstButton.frame = CGRectMake(20, 240, 50, 50);
secondButton.frame = CGRectMake(390, 240, 50, 50);
}
else if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)
{
firstButton.frame = CGRectMake(20, 240, 50, 50);
secondButton.frame = CGRectMake(390, 240, 50, 50);
}
else
{
firstButton.frame = CGRectMake(80, 390, 50, 50);
secondButton.frame = CGRectMake(190, 390, 50, 50);
}
}
Если iPhone не поворачивается до тех пор, пока не будет отображен контроллер DetailViewController, кнопки расположены правильно.Но если пользователь поворачивает iPhone при просмотре таблицы MasterViewController, а затем нажимает на элемент, когда открывается DetailViewController, кнопки расположены неправильно.
Так, как я могу или где я могу расположить кнопки изMasterViewController?Спасибо за помощь!