单独页面上的 UIPickerView
我正在开发 iPhone 应用程序。最初,我的选择器视图位于同一屏幕中,因此这只是一个一页应用程序。剥皮后,我意识到我希望选择器视图位于它自己的单独页面上。所以我就这么做了。但是,我的 pickerview 最初会更新同一页面上的 uilabels 和其他对象。如何让我的 pickerview 从新视图访问这些对象?
- (IBAction)ShowPickerAction:(id)sender {
if (self.theView == nil) {
theView = [containerView initWithNibName:@"containerView" bundle:nil];
theView.parentView = self;
}
self.theView.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:self.theView animated:YES];
这
就是我用来调用新视图的方法。但上述代码的第 3 行给出了错误“选择器 initWithNibName:bundle 没有已知的类名”。我认为该错误与我在头文件中做错的事情有关。我的新类称为containerView。所以我在标题中这样做了:
@interface ViewController : UIViewController {
containerView *theView;
但这给了我错误“未知类型名称containerView”,即使我确实有一个名为containerView的类!
I am working on an iPhone app. Initially, I had my pickerview in the same screen so this was just a one page app. After skinning it i realized that i want the pickerview on it's own separate page. So i did that. However, my pickerview originally would update uilabels and other objects on that same page. How can I have my pickerview access those objects from it's new view?
- (IBAction)ShowPickerAction:(id)sender {
if (self.theView == nil) {
theView = [containerView initWithNibName:@"containerView" bundle:nil];
theView.parentView = self;
}
self.theView.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:self.theView animated:YES];
}
That is the method I am using to call my new view. But line 3 of the above code gives me the error "No known class name for selector initWithNibName:bundle". I think that error is related to something that i did wrong in my header file. My new class is called containerView. So i did this in my header:
@interface ViewController : UIViewController {
containerView *theView;
But that gives me the error "Unknown type name containerView" even though i do have a class named containerView!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
查看 uiappdelegate 协议或尝试通过静态函数将值传递到上一页。
Look into uiappdelegate protocol or try passing values to through a static function to the previous page.
使用委托将信息来回传递到实例化选取器视图的视图对象。您希望保持代码耦合尽可能松散,特别是如果您想将其放入下一个项目中。使用委托和/或块是一些最好的方法。
Use a delegate to pass information back and forth to the view object that instantiatrd the picker view. You want to keep your code coupling as loose as possible, especially if you might like to drop it into your next project. Using a delegate and/or blocks are some of the best ways.