好吧,我注意到你的代碼有點奇怪。
您是否將寬度的大小添加到aRect的x位置的原點? aRect.origin.x + = aRect.size.width;
IM假設你想這是右上角....
你可以取消你的.m文件中的代碼,使它像這樣:
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
Return YES; // for supported orientations
//otherwise return (interfaceOrientation == UIInterfaceOrientationLandscape); if you want only landscape mode.
}
或者什麼,我會如果你想佈置你的子視圖在您的情況做的是使用didRotateFromIntferfaceOrientation:像這樣:
(void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
[self layoutSubviews];
}
也layoutSubviews
- (void)layoutSubviews
{
NSLog(@"layoutSubviews called");
...recalc rects etc based on the new self.view.bounds...
}
它的工作原理是這樣的。
PK
是的,我正在嘗試這種方式在彈出視圖中間的右側對齊。通過在原點中添加寬度,我可以在啓動應用程序時將它放置在正確的位置。問題出現在我改變方向時。 – Abhinav 2010-10-04 23:24:09
所以你應該嘗試的是didRotateFromInterfaceOrientation我會更新我的文章,你可以這樣做。 – Pavan 2010-10-04 23:25:12
只是一個問題,你有一個標籤欄在你的應用程序? – Pavan 2010-10-04 23:35:17