在 UIPickerView 中选择某些内容时发生某些事情 [英] Making something happen when something is selected in a UIPickerView
本文介绍了在 UIPickerView 中选择某些内容时发生某些事情的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在创建一个使用 UIPickerView 的应用程序.我做了这个视图,但我试图让某个按钮改变它的作用.请帮忙.
I was working on creating an app that uses a UIPickerView. I made the view but I am trying to make a certain button change what it does. Please help.
推荐答案
UIPickerView 和许多其他控件使用委托模式来通知您正在发生的事件.要使用它,将
添加到您的类类型定义(@interface 行),然后将 UIPickerView 的委托设置为您的类,如下所示:
UIPickerView and many other controls use delegate pattern to inform you about events happening.
To use it add <UIPickerViewDelegate>
to your class type definition(@interface line) and after that set the delegate of UIPickerView to your class like this:
myUIPickerView.delegate = self;
然后可以写如下method 和 row
是你想要的索引:
Then you can write the following method in your class and row
is the index you want:
- (void)pickerView:(UIPickerView *)pickerView
didSelectRow:(NSInteger)row
inComponent:(NSInteger)component
{
switch(row)
{
//...
}
}
这篇关于在 UIPickerView 中选择某些内容时发生某些事情的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文