一个 UIViewController 中有 2 个视图

发布于 2024-12-28 07:10:58 字数 133 浏览 4 评论 0原文

我需要知道如何实现下图的目的(联系信息视图和查询视图),即使不编写代码,任何建议都会很棒。

图片:

在此处输入图片描述

I need to know just how to achieve the purpose of the image below (Contact info view and Inquiry view) any suggestion will be great even without writing code.

the image:

enter image description here

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

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

发布评论

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

评论(3

苦行僧 2025-01-04 07:10:58
  1. 将两个具有相同框架的视图放置在一个视图控制器中并制作
    其中隐藏了。当用户将联系信息切换为查询时
    隐藏另一个视图,只需更改视图的隐藏属性即可。
  2. 如果这些视图是 UITableView,则使用一个 UITableView
    不同的数据源并将逻辑更改为 UITableView 委托
    方法。
  1. Place two views with identical frame in one viewcontroller and make
    on of them hidden. When user switch Contact Info to Enquiry then
    make hidden another view, just change hidden property for views.
  2. If those views is a UITableView then use one UITableView with
    different datasources and change logic into UITableView delegate
    methods.
二智少女 2025-01-04 07:10:58

在按钮控制器下方放置两个视图彼此重叠,一旦收到点击,就会显示一个视图并隐藏另一个视图......它非常简单,实际上希望这会有所帮助。

Just below your button controller put two view overlapping each other and once a tap s received show the one and hide the other... its pretty simple actually hope this helps.

孤千羽 2025-01-04 07:10:58

类似的东西应该可以工作:

self.contactInfoView = [[UIView alloc]init];//whatever you need
self.enquiryView = [[UIView alloc]init];//same here, do whatever you need
//customize you views
UIButton *contactInfoButton = [UIButton buttonWithType:UIButtonTypeCustom];
UIButton *enquiryButton = [UIButton buttonWithType:UIButtonTypeCustom];
//customize the buttons
[contactInfoButton addTarget:self action:@selector(showContactView) forControlEvents:UIControlEventTouchUpInside];
[enquiryButton addTarget:self action:@selector(showEnquiryView) forControlEvents:UIControlEventTouchUpInside];

然后使用两种方法来显示视图。可以很简单,例如:

-(void)showContactView {
  self.enquiryView.hidden = YES;
  self.contactInfoView.hidden = NO;
}

希望有帮助

Something like that should work:

self.contactInfoView = [[UIView alloc]init];//whatever you need
self.enquiryView = [[UIView alloc]init];//same here, do whatever you need
//customize you views
UIButton *contactInfoButton = [UIButton buttonWithType:UIButtonTypeCustom];
UIButton *enquiryButton = [UIButton buttonWithType:UIButtonTypeCustom];
//customize the buttons
[contactInfoButton addTarget:self action:@selector(showContactView) forControlEvents:UIControlEventTouchUpInside];
[enquiryButton addTarget:self action:@selector(showEnquiryView) forControlEvents:UIControlEventTouchUpInside];

and then make 2 methods to show the views. Can be simple like:

-(void)showContactView {
  self.enquiryView.hidden = YES;
  self.contactInfoView.hidden = NO;
}

Hope it helps

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