사용자가 배경 그림을 변경할 수 있도록 4 개의 UIButton이있는 처음 4 개의 ImageView가 있습니다. 그건 완벽하게 작동합니다. 그렇지만 ImageViews에 4 개의 UIButton이 있는데 전화 번호를 불러야합니다. 내가 그것을 실행할 때 그것을 클릭하면 아무것도 일어나지 않기 때문에 그것은 버튼을 호출하는 것 같다. 여기 내 코드는 다음과 같습니다.전화 번호로 4 UIButtons 설정 Xcode
#import "ViewController.h"
@interface ViewController()
{
UIImagePickerController *imagePickerController;
UIImagePickerController *imagePickerController2;
UIImagePickerController *imagePickerController3;
UIImagePickerController *imagePickerController4;
}
@end
@implementation ViewController
@synthesize firstImageView, secondImageView, thirdImageView, fourthImageView;
- (void)viewDidLoad
{
[super viewDidLoad];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *image1 = [info objectForKey:UIImagePickerControllerOriginalImage];
NSData *data = UIImagePNGRepresentation(image1);
NSString *myGrabbedImage = @"myGrabbedImage.png";
NSArray *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentDirectory = [path objectAtIndex:0];
NSString *fullPathToFile = [documentDirectory stringByAppendingPathComponent:myGrabbedImage];
[data writeToFile:fullPathToFile atomically:YES];
if (picker == imagePickerController) {
[[self firstImageView]setImage:image1];
} else if (picker == imagePickerController2) {
[[self secondImageView]setImage:image1];
} else if (picker == imagePickerController3) {
[[self thirdImageView]setImage:image1];
} else {
[[self fourthImageView]setImage:image1];
}
[self dismissViewControllerAnimated:YES completion:nil];
}
- (IBAction)firstChangeButton:(id)sender
{
imagePickerController = [[UIImagePickerController alloc]init];
[imagePickerController setDelegate:self];
[imagePickerController setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
[self presentViewController:imagePickerController animated:YES completion:nil];
}
- (IBAction)secondChangeButton:(id)sender
{
imagePickerController2 = [[UIImagePickerController alloc]init];
[imagePickerController2 setDelegate:self];
[imagePickerController2 setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
[self presentViewController:imagePickerController2 animated:YES completion:nil];
}
- (IBAction)thirdChangeButton:(id)sender
{
imagePickerController3 = [[UIImagePickerController alloc]init];
[imagePickerController3 setDelegate:self];
[imagePickerController3 setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
[self presentViewController:imagePickerController3 animated:YES completion:nil];
}
- (IBAction)fourthChangeButton:(id)sender
{
imagePickerController4 = [[UIImagePickerController alloc]init];
[imagePickerController4 setDelegate:self];
[imagePickerController4 setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
[self presentViewController:imagePickerController4 animated:YES completion:nil];
}
- (IBAction)callFirst:(id)sender
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:0739421700"]];
}
- (IBAction)callSecond:(id)sender
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:073942100"]];
}
- (IBAction)callThird:(id)sender
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:0739421700"]];
}
- (IBAction)callFourth:(id)sender
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:0739421700"]];
}
@end
뭐가 잘못 되었나요?
버튼이 이미지보기 위에 있는지 확인하십시오. 그렇지 않은 경우 IB에서 순서를 변경하십시오. – Pandafox
'UIButtons'에 설정 태그를 제안하고'didFinishPickingMediaWithInfo' –