活动指示器不在子视图的中心(与父视图的大小不同)
我正在尝试使用下面的代码将旋转器置于页面中间的中心。
self.aSpinner.center = self.view.center;
但是,当我运行该程序时,旋转器似乎不在中心
有什么办法可以解决这个问题吗?
编辑:
我发现了问题。这并不是说旋转器不在中心,而是子视图与其父视图具有不同的边界。
我在代码中做了类似的事情:
self.navcon = [[UINavigationController alloc]init];
self.photoViewTable = [[PhotoTableViewController alloc]init];
self.loadingPage = [[LoadingPageViewController alloc]init];
[self.photoViewTable.view addSubview:loadingPage.view];
[navcon pushViewController:photoViewTable animated:NO];
[self.window addSubview:navcon.view];
如何我可以将 loadingPage
视图的大小设置为等于父视图吗?
I am trying to center a spinner in the middle of the page using the code below.
self.aSpinner.center = self.view.center;
However when when I run the program, the spinner does not seem to be in the center
Is there any way to fix this?
EDIT:
I found the problem. It's not that the spinner is not in the center, but instead the subview has different bounds than its superview.
I am doing something like this in my code:
self.navcon = [[UINavigationController alloc]init];
self.photoViewTable = [[PhotoTableViewController alloc]init];
self.loadingPage = [[LoadingPageViewController alloc]init];
[self.photoViewTable.view addSubview:loadingPage.view];
[navcon pushViewController:photoViewTable animated:NO];
[self.window addSubview:navcon.view];
How can I set the size of loadingPage
view to be equal to the parent view?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
设置中心属性可能还不够。如果您的框架正在调整大小,我还将设置微调器视图的自动调整大小蒙版:
Setting the center properties might not be enough. In case your frame is being resize i will also set the autoresize mask of the spinner view:
尝试在 ViewDidAppear 上执行此操作,视图有正确的 self.bounds
我不检查 self.center。
工作正确!
检查自身是否有视图或自身是否被查看
Try do it on ViewDidAppear, there is correct self.bounds of view
I don't check self.center.
Work correct!
Check self has view or self is view