2011-11-11 35 views
0

即時通訊iPhone新手,我有一個登錄屏幕在Iphone中,當我運行時,它只顯示在半屏上,然後我改變了它在橫向模式下顯示的登錄屏幕的方向,但我希望當我啓動應用程序時在縱向模式下以橫向模式顯示並導航到另一個屏幕時縱向模式下的橫向模式,怎麼樣?請任何人幫我如何從iPhone中的肖像啓動橫向視圖?

- (BOOL)shouldAutorotateToInterfaceOrientation:() 
{ 
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation]; 
if (orientation == UIDeviceOrientationLandscapeLeft || 
     orientation == UIDeviceOrientationLandscapeRight) 
{ 
    return YES; 
} 
else if (orientation == UIDeviceOrientationPortrait ||orientation == UIDeviceOrientationPortraitUpsideDown) 
{ 
    return NO; 
} 
} 

使用這些代碼不能在橫向模式下工作在縱向,但我改變了它的工作方向。

+0

u能更具體。 – iamsult

+0

嗨,我的問題是如何在縱向發佈橫向視圖?感謝您的回覆。 – sankar

回答

0
-(void) viewWillAppear:(BOOL)animated{ 
    UIInterfaceOrientation orientation = [[UIDevice currentDevice] orientation]; 

    [self willAnimateRotationToInterfaceOrientation:orientation duration:0]; 


} 

-(void) willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration 
{ 
    if(toInterfaceOrientation == UIInterfaceOrientationPortrait || toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) 
    { 
    set the view for potrait 
    } 
    else if(toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) 
    { 
    set the view for landscape 
    } 


} 
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    // Overriden to allow any orientation. 
    return YES; 
} 

希望這個幫助你。

+0

感謝您的回覆 – sankar

+1

如果你得到了答案你應該upvote它。 – iamsult

0

這是什麼意思:「縱向景觀」?你有這個或那個,不能同時擁有兩個(除非你有iPhone; P)

在plist文件中,你可以確定哪個模式將在應用程序啓動時啓動:)「Initial interface orientation」with values爲四個方向中的每一個。設置這個東西的最快方法。雖然在應用程序時,旋轉或不管理以後,你應該使用

-(BOOL)shouldAutorotateToInterfaceOrientation:

希望這有助於:)

相關問題