0

我遇到了UIPickerView的連接問題。 我的viewController類看起來是這樣的:UIPickerView連接

@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出現在奧特萊斯,而不是在引用網點(對什麼是在教程中所示)。 如何建立連接?我該如何連接它? 我希望點擊一個按鈕,其動作也在上面的類中註冊時顯示PickerView。

回答

0

我想你可能只是有一個誤會。我創建了類似於您所描述的類:

@interface MyViewController:UIViewController {UIPickerView * pickerView; }

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

然後我打開了xib。我右鍵單擊文件的所有者(或者如果您沒有雙按鈕鼠標,則單擊鼠標右鍵),這會在MyViewController上列出所有Outlet的列表。我發現這比按大多數教程建議你做的ctrl單擊要容易得多。然後我點擊並從pickerView旁邊的圓圈拖到pickerView。放開鼠標按鈕,它連接得很好。

Interface Builder screenshot