gpt4 book ai didi

objective-c - 事件指示器不在 subview 的中心(与父 View 的大小不同)

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:55:16 26 4
gpt4 key购买 nike

我正在尝试使用以下代码将微调器置于页面中间。

self.aSpinner.center = self.view.center;

但是当我运行程序时,微调器似乎不在中心

Screen shot of iPad simulator; activity indicator in blank view to right of center

有什么办法可以解决这个问题吗?

编辑:

我发现了问题。并不是微调器不在中心,而是 subview 与其父 View 具有不同的边界。

Screenshot of iPad simulator; view with subviews and activity indicator to right of 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 View 的大小等于父 View 的大小?

最佳答案

[spinner setCenter:CGPointMake(kScreenWidth/2.0, kScreenHeight/2.0)];

关于objective-c - 事件指示器不在 subview 的中心(与父 View 的大小不同),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6234539/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com