iPad:在 UINavigationController 中自定义导航项的正确方法
这与我几天前问的一个问题有关: iOS:从 UITabBar/UINavigationController 应用程序中的视图设置 nib 子视图中的文本
我需要将搜索栏和按钮放在导航控制器的右上角,这超出了标准UINavigationController.navigationItem.rightBarButtonItem 允许的单个按钮,因此我使用 UIBarButtonItem 的 initWithCustomView: 方法从 nib 文件加载视图。
在我的特定情况下,我已将视图作为单独的项目放在该表单的主视图文件中。
我遇到的问题是加载和显示顺序,我想知道这是否是正确的方法?
似乎发生了以下情况:
我的主窗口上的 viewDidLoad 被调用 我的主窗口上的 viewDidAppear 被调用,我设置了 rightBarButtonItem 然后我想填充该搜索栏上的文本字段,但由于按钮项的视图加载发生在主线程中,我不知道它何时出现。
我是否会更好地为搜索栏和按钮创建一个带有 nib 的新类,然后该类将具有 viewDidLoad/viewDidAppear,然后我可以创建一个委托函数,以便我可以将文本“出队”以进入搜索栏?
或者,我错过了一些非常简单的东西吗?
This relates to a question I asked a few days ago: iOS: Setting text in nib subview from view in UITabBar/UINavigationController application
I need to put the search bar and buttons on the top right of a navigation controller, this is more than the standard single button that UINavigationController.navigationItem.rightBarButtonItem allows so I am using the initWithCustomView: method of UIBarButtonItem to load a view from a nib file.
In my particular case, i've put the view as a seperate item in the main view file for that form
The problem i've got is load and display sequence and I wanted to know if this was the right approach to this?
It seems that the following happens:
viewDidLoad on my main window gets called
viewDidAppear on my main window gets called and I set up rightBarButtonItem
I then want to populate a text field on that search bar but because the loading of the view for the button item happens in the main thread, I don't know when it's appeared.
Would I be better to create a new class with nib for the search bar and buttons which would then have a viewDidLoad/viewDidAppear and I could then create a delegate function so I could 'deQueue' the text to go into the search bar?
Or, am I missing something really simple?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论