2012-09-25 27 views
2

有人可以解釋iOS在界面旋轉時的作用。旋轉iPhone之後,一個視圖出現佈局問題。似乎視圖設置了一個新的框架,邊界或其他什麼,不知道。無論如何,一旦佈局問題永遠消失,界面旋轉後。因此,界面旋轉時必須設置視圖。界面旋轉對UIView做了什麼?

I'm從護理文件加載查看,並用navigationcontroller表現出來:

BirthdayReminderWidgetConfigViewController *vc = [self.storyboard 
    instantiateViewControllerWithIdentifier:@"BirthdayConfigController"]; 
self.navigationController pushViewController:vc animated:true]; 

也許有一些設置我爲了顯示視圖不旋轉接口正確的事情。

從來就得到了與從筆尖文件加載如下一個圖的佈局問題:

該項目包含一個MainStoryboard。在那裏,我從一個nib文件加載一個視圖。

NSArray *xib = [[NSBundle mainBundle] loadNibNamed:@"View" owner:self options:nil]; 
self.configViewController = [xib objectAtIndex:0]; 

,故事情節有一個導航控制器和加載視圖是這個樣子:

if (currentWidgetConfigViewController != nil) 
    { 
     [self.navigationController pushViewController:currentWidgetConfigViewController animated:true]; 
    } 
在我看來沒有錯

所以呢? (第一個問題) 但現在的問題。

我設計的是什麼:

enter image description here

什麼的iOS確實是以下

enter image description here

控件沒有排列好。

除此之外,隨着對新觀點我打開了一個PeoplePicker與代碼按鈕:

[self presentViewController:self.picker animated:YES completion:nil]; 

關人民與[self.picker dismissViewControllerAnimated:true completion:nil];選取器後,我得到這樣的結果:

enter image description here

那麼這裏出了什麼問題?在你看來

+0

每當視圖旋轉時,您必須更改視圖框架。由於橫向視圖的縱向高度小於縱向模式,因此如果您的任何視圖在橫向上低於320或縱向上超過320,被隱藏起來。希望你明白這一點。 –

回答

1

覆蓋-setFrame:-setBounds:,看看會發生什麼:

- (void) setFrame: (CGRect) newFrame 
{ 
    NSLog(@"New frame: %@", NSStringFromCGRect(newFrame)); 
    [super setFrame:newFrame]; 
} 

此外,transform通常是迴轉期間。 Orientation Zoo可能會有幫助,它是一個示例Xcode項目,顯示了各種旋轉用例中會發生的情況。但是很長一段時間沒有碰它,所以我不知道它是否仍然有效。