自定义 iPhone 应用程序标签栏
好吧,这看起来很简单,但我还没有找到太多与此相关的文档或帖子。基本上,我想在我的应用程序底部有一个完全自定义的选项卡栏。作为 iPhone 开发新手,我认为我可以执行以下操作:
- 将自定义图像放在底部 屏幕充当选项卡按钮。
- 创建一个 UIView (我们称之为 “ContentView”)来填充其余部分 将显示的屏幕 相应选项卡的 NIB。这 “ContentView”位于 main 内部 NIB 的 UIView。
- 将图像“按下”动作连接到 控制器管理这一切。
不过,我不确定如何使用此方法将适当的 NIB 加载到“ContentView”中。我可以从控制器中的“Touch Up”操作方法动态地将 NIB 加载到“ContentView”UIView 中吗?
这整件事让我感到不安。
有更好的办法吗?
Alright, this seems simple enough but I haven't found much documentation or posts regarding this. Basically, I want to have a completely custom tab bar at the bottom of my app. Being new to iPhone dev I thought I could do the following:
- Place custom images on bottom of
screen to act as tab buttons. - Create a UIView (lets call it
"ContentView") to fill the rest of
the screen that will display the
appropriate tab's NIB. This
"ContentView" is inside the main
UIView for the NIB. - Hook up image "press" actions to the
controller managing all this.
I'm not sure how I would go about loading the appropriate NIB into the "ContentView" with this method though. From the "Touch Up" action method in the controller can I dynamically load a NIB into that "ContentView" UIView?
Something about this whole thing makes me uneasy.
Is there a better way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为了解决您的问题,我将创建一个带有 UIView 及其关联内容的笔尖。将笔尖连接到 UIViewController。这将是每个选项卡的内容。根据需要创建尽可能多的 UIView-UIViewController 组合。
从笔尖创建并加载 UIViewController
当用户触摸选项卡时,使用将笔尖中的 UIView 作为子视图添加到主内容视图, 。使用
当用户按下其他选项卡时,会将其他笔尖加载到内存中,并将其 UIView 作为子视图添加到主内容视图中。
如果视图已在内存中,您可以使用以下方法显示和隐藏子视图。
我认为这会起作用。
To solve your problem I would create a nib with a UIView and its associated content in it. Connect the nib to a UIViewController. This will be the content of each tab. Create as many of these UIView-UIViewController combination as needed.
When the user touches a tab, create and load the UIViewController from the nib using
Add the UIView in the nib to the main content view as a subview. Use
As the user presses other tabs load the other nibs into memory and add their UIView into the main content view as a subview.
If a view is already in memory you can show and hide subviews with the following methods.
I think that would work.
您可以通过以下方法解决此问题:
使用相同的选项卡栏图像和自定义按钮创建不同的视图(在 IBAction 上加载视图以进行按钮单击:toucp 内部),或者您可以为同一视图创建不同的视图(这样您就可以隐藏视图并仅显示视图)相应地一次查看一个视图)。
并且您可以加载视图(如果您的应用程序是基于视图的,则在窗口上添加其他视图,否则对于基于导航的应用程序,您需要推送导航控制器的ViewController。
这是一项棘手的任务,但您需要处理这个问题。
You can solve this by,
either make different views with same tab bar image and custom button(load view on IBAction for button click:toucp up inside) or you can make different views for the same view(so you can hide views and show only one view at a time accordingly).
and you can load view (if you app is view based then add other views on window otherwise for navigation based app you need to pushViewController of navigation controller.
This is a tricky task but you need to handle this.