选择一个选择器会导致UIbutton图像更改
|
我一直在寻找一种构建UIpicker的方法,选择该行将导致UIbutton图像的更改。通常的if,else方法更改按钮似乎在这里不起作用。有谁知道该怎么做?
这是我找到并正在使用的模型代码。我该如何修改?
非常感谢。
@synthesize button;
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
arrayColors = [[NSMutableArray alloc] init];
[arrayColors addObject:@\"Orange\"];
[arrayColors addObject:@\"Yellow\"];
[arrayColors addObject:@\"Green\"];
[arrayColors addObject:@\"Blue\"];
[arrayColors addObject:@\"Indigo\"];
[arrayColors addObject:@\"Violet\"];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning]; // Releases the view if it doesn\'t have a superview
// Release anything that\'s not essential, such as cached data
}
- (void)dealloc {
[arrayColors release];
[super dealloc];
}
#pragma mark -
#pragma mark Picker View Methods
- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)thePickerView {
return 1;
}
- (NSInteger)pickerView:(UIPickerView *)thePickerView numberOfRowsInComponent:(NSInteger)component {
return [arrayColors count];
}
- (NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
return [arrayColors objectAtIndex:row];
}
- (void)pickerView:(UIPickerView *)thePickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
NSLog(@\"Selected Color: %@. Index of selected color: %i\", [arrayColors objectAtIndex:row], row);
}
@end
没有找到相关结果
已邀请:
1 个回复
净爽