如果我从Pickerview中选择了任何项来显示相关的警告消息,那么选择器视图的代码是什么?在选择器视图包含"红色",黄色","块","绿色"从选择器视图,如果我选择红色警报消息"这是红色"。
您可以使用选择器委托方法。
-(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对象中有了选择的值,然后在警报消息中使用该对象。
你可以参考这个讨论
设置委托,使用- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component
in - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
请阅读Apple文档:http://developer.apple.com/library/ios/文档/uikit/引用/UIPickerViewDelegate_Protocol/引用/UIPickerViewDelegate.html #//apple_ref/occ/intf UIPickerViewDelegate