更改到特定部分内的另一个视图

发布于 2024-12-29 05:00:59 字数 272 浏览 2 评论 0原文

iOS 应用程序中的 UIView 包含三个部分。我可以知道如何才能仅在其中一个部分中更改为另一个视图吗?

例如:

main uiview with 3section

当我按下下一页按钮时,第 2 部分将更改为另一个 UIView。但第 1 节和第 3 节仍将保留。

有什么帮助吗?

太感谢了!

There are three sections in my UIView in the iOS application. May I know how can I only change to another view within one of the sections only?

For example:

main uiview with 3 section

When I press the next page button, section 2 will change to another UIView. However sections 1 and sections 3 will still remain.

Any help?

Thank you so much!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

傲影 2025-01-05 05:00:59

在“下一页”按钮上单击功能只需执行此

[pageSectionTwo removeFromSuperview];

[self addSubview:pageSectionTwoNewView];

“pageSectionTwo”,这是应该替换以获取另一个视图的视图
“pageSectionTwoNewView”这是第 2 部分中的初始视图替换后将显示的视图

on Next Page button click function just do this

[pageSectionTwo removeFromSuperview];

[self addSubview:pageSectionTwoNewView];

"pageSectionTwo" this is the view which should be replaced to get another View in place
"pageSectionTwoNewView" this is the View which will show after you initial View in section 2 replaces

兔姬 2025-01-05 05:00:59

添加另一个 UIButton,将其框架设置为与第 2 部分中的 UIButton 相同,然后隐藏它。

UIButton *btn2 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
btn2.frame = btn1.frame;
btn2.hidden = YES;
[self.view addSubView:btn2]; // This will add btn2 to you view

当您准备更改 UIButton 时,请执行以下操作

btn1.hidden = YES;
btn2.hidden = NO;

这将隐藏第一个并显示第二个。

Add another UIButton, set its frame the same as UIButton in section 2, and hide it

UIButton *btn2 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
btn2.frame = btn1.frame;
btn2.hidden = YES;
[self.view addSubView:btn2]; // This will add btn2 to you view

When you are ready to change your UIButtons, do the following

btn1.hidden = YES;
btn2.hidden = NO;

That will hide the first one and show the second.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文