好吧,我注意到你的代码有点奇怪。
您是否将宽度的大小添加到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