1

情况就是这样,我是新手——所以我可能完全走错了路。

我正在构建一个具有多个视图的应用程序;在其中一个视图中,我需要用户从下拉列表(UIPickerView)中进行选择-> 为简单起见,我们称该视图为“PC”,其中包含 PC.h 和 PC.m 文件。

通过 IB,我能够将 UIPickerView 对象拖放到 PC 视图中,并在我的 ViewController.h 和 ViewController.m 文件中初始化该“对象”。意思是,我能够加载视图、在视图中填充数据等等。

我的挑战/问题是-我希望隐藏 UIPicker,直到用户单击 PC 视图上的按钮,然后我想显示 UIPicker 并在用户从菜单中选择某些内容后再次隐藏它。

我已经搜索和搜索,找不到任何东西,所以这里的任何帮助表示赞赏!

4

1 回答 1

1

assuming that your UIPickerView instance (object) is called pv;

This is how your header-file may look like:

@interface YourViewController : UIViewController 
{
    IBOutlet UIPickerView *pv;
}

@property (nonatomic, retain) UIPickerView *pv;

@end

You then need to connect the pv-instance within the InterfaceBuilder to your Picker-View.

Trivial Approach:

somewhere in your viewDidLoad of the embedding view-controller:

pv.hidden = YES;

within the button action method (connected to your button-touch-up-instide event):

pv.hidden = NO;

within the action method of your "menu"

pv.hidden = YES;
于 2011-03-26T15:46:02.790 回答