【发布时间】:2014-12-05 06:24:21
【问题描述】:
我希望在我的 iOS 应用程序中,用户可以在单击 UIButton 时选择一些字段。
我希望当用户单击UIButton 时选择字段,按钮的图像应该更改并打开我的MMPickerView,并且当用户再次单击时UIButton 应该被取消选择并在UIButton 中显示上一个图像并执行暂时没有打开MMPickerview。
这是我的代码:
- (IBAction)showPickerViewButtonPressed:(id)sender {
if( (_button.selected = !_button.selected))
{
UIImage *bimage=[UIImage imageNamed: @"play.jpg"];
[_button setImage:bimage forState:UIControlStateNormal];
}
else
{
[MMPickerView showPickerViewInView:self.view
withStrings:_stringsArray
withOptions:@{MMbackgroundColor: [UIColor blackColor],
MMtextColor: [UIColor whiteColor],
MMtoolbarColor: [UIColor blackColor],
MMbuttonColor: [UIColor whiteColor],
MMfont: [UIFont systemFontOfSize:18],
MMvalueY: @3,
MMselectedObject:_selectedString}
completion:^(NSString *selectedString) {
_label.text = selectedString;
_selectedString = selectedString;
}];
}
}
【问题讨论】:
标签: ios objective-c uibutton uipickerview ibaction