UIPickerView 连接

发布于 2024-10-17 23:09:02 字数 497 浏览 7 评论 0原文

我的 UIPickerView 连接有问题。 我的 viewController 类如下所示:

@interface MyViewController: UIViewController <UITextFieldDelegate, UIPickerViewDataSource, UIPickerViewDelegate>
{
IBOutlet UIPickerView *pickerView;/this is what it says in all tutorials
//other textfields
}
 @property..of textfields, label, nsstring
@end

在界面生成器中,当我按住 Ctrl 键并单击文件所有者时,我的 pickerview 出现在 Outlet 中,而不是引用的 Outlet 中(与教程中显示的内容相反)。 我如何建立连接?我将它连接到什么? 我希望在单击按钮时显示 PickerView,该按钮的操作也已在上面的类中注册。

I'm having a problem with the connections of UIPickerView.
My viewController class looks like this:

@interface MyViewController: UIViewController <UITextFieldDelegate, UIPickerViewDataSource, UIPickerViewDelegate>
{
IBOutlet UIPickerView *pickerView;/this is what it says in all tutorials
//other textfields
}
 @property..of textfields, label, nsstring
@end

In the interface builder, when i ctrl+click on the file's owner, my pickerview appears in Outlets and NOT in referencing outlets(against what is shown in tutorial).
How do I make the connections? and what do I connect it to?
I want the PickerView to be displayed on click of a button whose action is also registered in the above class.

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

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

发布评论

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

评论(1

遗失的美好 2024-10-24 23:09:02

我想你可能只是有一个误会。我创建了一个与您所描述的类似的类:

@interface MyViewController : UIViewController {
UIPickerView *pickerView;
@property

(非原子,保留) IBOutlet UIPickerView *pickerView;

然后我打开了xib。我右键单击文件的所有者(如果没有两键鼠标,则单击 cmd),这将显示 MyViewController 上所有 Outlet 的列表。我发现这比大多数教程建议您按 Ctrl 键单击要容易得多。然后我单击并从 pickerView 旁边的圆圈向下拖动到 pickerView。放开鼠标按钮,它就可以正常连接了。

界面生成器屏幕截图

I think you might just have a misunderstanding. I created a class similar to what you described:

@interface MyViewController : UIViewController {
UIPickerView *pickerView;
}

@property (nonatomic, retain) IBOutlet UIPickerView *pickerView;

Then I opened up the xib. I right-clicked on the File's Owner (or cmd-click if you don't have a two button mouse), which brought up a list of all of the Outlets on MyViewController. I find this a lot easier than the ctrl-clicking that most of the tutorials suggest you do. Then I clicked and dragged from the circle next to pickerView down to the pickerView. Let go of the mouse button and it connects just fine.

Interface Builder screenshot

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