2010-02-02 115 views
1

我正在研究一個應用程序,我希望視圖在旋轉設備時發生相當大的變化。我知道在Interface Builder中可以改變方向並在那裏設置佈局,但是當我將它旋轉到縱向時,視圖與橫向相同。有沒有辦法獨立設置兩個視圖,也許使用兩個筆尖?以方向更改視圖佈局

乾杯, JP

回答

2

我不知道你是否能在IB做到這一點,但我知道你可以在代碼中做到這一點。你需要觀察UIDeviceOrientationDidChangeNotification通知:

(在viewDidLoad中...)

[[NSNotificationCenter defaultCenter] 
     addObserver:self 
     selector:@selector(updateViewOnRotate:) 
     name:UIDeviceOrientationDidChangeNotification 
     object:nil]; 

....

-(void) updateViewOnRotate:(NSNotification *notification) { 
    // update the views 
}