2013-09-16 3 views
0

По-прежнему возникают проблемы с нажатием нового UIView на вращение. Я следую примеру, который я нашел. Это так круто. В этот момент он выдает ошибку с ошибкой;Нажатие раскадровки на новый UIView

«NSInvalidArgumentException», причина: «Приложение попыталось представить контроллер модального вида nil для цели».

controller nvs = [self.storyboard instantiateViewControllerWithIdentifier:@"LandscapeView"]; 
[self.navigationController pushViewController:nvs animated:YES] 

Очевидно, что я здесь что-то отсутствует. То, что я пытаюсь достичь, - это другое представление, которое вставляется в стек, когда пользователь поворачивает свое устройство. Как календарь.

Целого заявление

LandscapeViewController * nvs; 

- (недействительный) updateLandscapeView { UIDeviceOrientation deviceOrientation = [UIDevice CurrentDevice] .orientation;

if (UIDeviceOrientationIsLandscape(deviceOrientation) && self.presentedViewController == nil) 

{ 
    if (!self.landscapeViewController) 
     //self.landscapeViewController = [[LandscapeViewController alloc] initWithNibName:@"LandscapeView" bundle:nil]; 

     //Set the location of the where you want the view to go i.e. the next view controller 
     nvs = [self.storyboard instantiateViewControllerWithIdentifier:@"LandscapeView"]; 
     //Push the view onto the device 
     [self.navigationController pushViewController:nvs animated:YES]; 

    if ([self respondsToSelector:@selector(presentViewController:animated:completion:)]) 
     [self presentViewController:self.landscapeViewController animated:YES completion:NULL]; 
    else 
     [self presentModalViewController:self.landscapeViewController animated:YES]; 
} 
else if (deviceOrientation == UIDeviceOrientationPortrait && self.presentedViewController != nil) 
{ 
    if ([self respondsToSelector:@selector(dismissViewControllerAnimated:completion:)]) 
     [self dismissViewControllerAnimated:YES completion:NULL]; 
    else 
     [self dismissModalViewControllerAnimated:YES]; 
}  

}

Заранее спасибо! Jeremy

ответ

0

Got it. Вместо этого pushViewController нажимает nvs, который был установлен за пределами инструкции. Я ссылался на него непосредственно при использовании self.landscapeViewController.

Ниже приведен код. Надеюсь, это поможет кому-то в будущем.

self.landscapeViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"LandscapeView"]; 
[self.navigationController pushViewController:self.landscapeViewController animated:YES]; 
Смежные вопросы