這是問題: 我希望用戶點擊按鈕並選擇按鈕所代表的圖像。有不止一個按鈕,用戶可以選擇不同的圖像,或者他/她點擊的每個按鈕都選擇相同的圖像。 如何在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