如果我从Pickerview中选择了任何项目以显示相关的警报消息,那么选择器视图的代码如何。 exe:如果我选择RED Alert消息“这是红色”,则选择器视图中的选择器视图包含“RED”,“JELL”,“BLOCK”,“GREEN”。 所以帮我解决问题。
答案 0 :(得分:1)
设置代理并使用- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
在- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
答案 1 :(得分:1)
您可以使用选择器委托方法。
-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
mString.text= [arrayNo objectAtIndex:row]; //mString is a NSString defined and the arrayNo is the NSArray that contain all your color data.
}
现在,您在mString对象中拥有所选值,然后在警报消息中使用该对象。
您可以参考this讨论