在我的應用程序中,我使用縱向導航控制器啓動secondviewcontroller,然後在第四個控制器中完成旋轉iPhone以顯示圖像。 現在的問題是: 如果目標我設置這樣的方向: IOS:在UINavigationController中鎖定方向
我可以用這個方法來旋轉我的形象:
- (void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
,它做工精細,但我可以不鎖定屬於導航控制器的所有視圖,因爲它們都旋轉il縱向和橫向。
第二個選項是設置目標以這樣的方式
,但這種結構不檢測的方向:
鑑於將會出現:
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
[self willRotateToInterfaceOrientation:orientation duration:1];
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
- (BOOL)shouldAutorotate
{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscape;
}
- (void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
if (toInterfaceOrientation == UIInterfaceOrientationPortrait || toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
{
}
else
{
}
}
else{
if (toInterfaceOrientation == UIInterfaceOrientationPortrait || toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
{
}
else
{
}
}
}
有什麼最佳方案? 感謝
我在其他viewcontroller中添加了這段代碼,我想鎖定,但方向是活動的......我該怎麼辦? – CrazyDev