проблемы с ротацией ios6

Я конвертирую свое приложение в ios6, но у меня возникают проблемы с вращением. Может ли кто-нибудь помочь мне, какие методы будут вызываться при повороте устройства


person ganesh manoj    schedule 19.11.2012    source источник


Ответы (4)


- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation) toInterfaceOrientation duration:(NSTimeInterval)duration 
{
    [self doLayoutForOrientation:toInterfaceOrientation]; 
}


- (void)doLayoutForOrientation:(UIInterfaceOrientation)orientation { 
if (UIInterfaceOrientationIsPortrait(orientation)) 
{
//set the frames here
}
else 
{
//set the frames here
} 
}

Это новые методы в iOS 6, где вы можете установить рамки в соответствии с ориентацией. Надеюсь, это будет полезно для вас.

person Krish    schedule 20.11.2012

- (BOOL) shouldAutorotate -(NSUInteger)supportedInterfaceOrientations

Это новые функции, добавленные в iOS 6.

person Rajan Balana    schedule 19.11.2012
comment
Используете ли вы какую-либо стороннюю структуру пользовательского интерфейса, например, three20 или что-то в этом роде? - person Rajan Balana; 19.11.2012
comment
Я не смогу ответить на вашу проблему, не посмотрев код страницы, на которой поворот не работает должным образом. - person Rajan Balana; 19.11.2012

 -(NSUInteger)supportedInterfaceOrientations

{
    return UIInterfaceOrientationMaskAll;
}

-(void)viewWillLayoutSubviews
{
if([self interfaceOrientation] == UIInterfaceOrientationPortrait||[self interfaceOrientation] ==UIInterfaceOrientationPortraitUpsideDown)
    {
     //set the frames here
    }
    else if ([self interfaceOrientation] == UIInterfaceOrientationLandscapeLeft||[self interfaceOrientation] == UIInterfaceOrientationLandscapeRight)
    {
      //set the frames here
    }
}

лучше пойти с этим, описанный выше метод будет вызываться каждый раз, когда вы меняете ориентацию устройства.

person Krish    schedule 19.11.2012

Обработка поворота с помощью этих методов

-(BOOL) shouldAutorotate
{
    return NO;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}

Если какой-то вид вращается, и вы не хотите, например, UIImagePickerController, просто создайте дочерний класс и переопределите первый метод.

person NaXir    schedule 22.11.2012