UIImageView
에는 두 개의 버튼 - 사진 촬영 버튼과 버튼 이미지 선택 버튼이 여러 개 있습니다. 지금까지 나는 두 개의 UIImageView
과 4 개의 버튼을 설정했습니다. 당신은 테이크 사진 버튼 중 하나를 클릭하면 동일한 프로세스에 작업을 수행합니다 :ImageView를 할당 할 다중 버튼 if 문
-(void)takePhoto:(id) sender {
UIImagePickerController *controller = [[UIImagePickerController alloc] init];
controller.sourceType = UIImagePickerControllerSourceTypeCamera;
[controller setDelegate:self];
[self presentModalViewController:controller animated:YES];
}
을 같은 대신 SourceTypeCamera의 SourceTypePhotoLibrary와 ChoosePhoto 버튼 간다. 이 과정이 완료되면 그것은이 함수로 전환 :
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
[self dismissModalViewControllerAnimated:YES];
theImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 690, 440)];
theImageView.userInteractionEnabled = TRUE;
[layout1 addSubview:theImageView];
[theImageView release];
[theImageView setImage:image];
takePhoto.hidden = YES;
choosePhoto.hidden = YES;
theImageView.clipsToBounds = YES;
imagetwo = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
[self dismissModalViewControllerAnimated:YES];
ImageView2 = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 690, 440)];
ImageView2.userInteractionEnabled = TRUE;
[layout2 addSubview:ImageView2];
[ImageView2 release];
[ImageView2 setImage:imagetwo];
takePhoto2.hidden = YES;
choosePhoto2.hidden = YES;
ImageView2.clipsToBounds = YES;
}
지금 내가 if 문을 필요가 있다고 생각 엑스 코드 당신이 중 하나를 누를 때 두 이미지를 표시하지 않도록 누르면되고있는 버튼 인식하도록 첫 번째 이미지보기 단추 또는 다른 이미지보기 단추. 나는이 진술이 무엇을 구성해야하는지 확신 할 수 없다. 만약 이라면 또는 choosePhotoisTouchedInside
을, 그 다음에는 첫 번째 ImageView 만 실행한다. 어떤 아이디어?
도움에 감사드립니다. – Ollie177
안녕하세요. 나는 당신이 제안한 것을했는데 큰 감사를 보낸다. 그러나 두 개의 버튼 태그에 대해 if 문을 어떻게 처리할지는 모르겠다. 왜냐하면 나의 if 문은 다음과 같이 보이기 때문이다. 'if (myTag == 1) {' }} 태그 1 또는 2를 누르면 태그 하나만 눌렀을 때와 반대로 이미지보기가 생성됩니다. – Ollie177
if (myTag == 1 || myTag == 2) {} – Rayfleck