2010年5月2日 星期日

[Iphone]如何變更橫屏座標



























如圖所示,其實要設定iphone固定住橫屏座標,就是這麼簡單,只要設定右圖的程式碼,就可簡單達到目的.
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
// setting default coordinate
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
這段程式中shouldAutorotateToInterfaceOrientation是UIViewController中的Function,我們只要繼承UIViewController並且覆寫,並設定interfaceOrientation == UIInterfaceOrientationLandscapeRight就可固定設定橫向座標.

如果照程式中的註解return YES; 那麼就可以隨著IPhone轉動變更座標.

1 則留言:

嘎嘎嘎