这是问题: 我希望用户点击按钮并选择按钮所代表的图像。有不止一个按钮,用户可以选择不同的图像,或者他/她点击的每个按钮都选择相同的图像。 如何在void方法中添加一个if结构来检查哪个按钮被按下?根据按下哪个按钮,使用UIImagePickerController更改正确按钮的图像
@implementation ViewController
@synthesize tegelEen,tegelTwee; //tegelEen is a button an so is tegelTwee
-(IBAction)Buttonclicked:(id)sender {
picController = [[UIImagePickerController alloc]init];
picController.delegate = self;
picController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentViewController:picController animated:YES completion:nil];
}
-(void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
UIImage *btnImage = [info objectForKey:UIImagePickerControllerOriginalImage];
//Now it changes both buttons but I want it to change only the one that was clicked.
[tegelEen setImage:btnImage forState:UIControlStateNormal];
[tegelTwee setImage:btnImage forState:UIControlStateNormal];
[self dismissViewControllerAnimated:YES completion:nil];
}
在此先感谢,是的,我对这种语言很新。
这正是我一直在寻找的,感谢吨:D – 2013-05-08 22:27:38