我对XCode和 我在制作照片拼贴App, 当我选择模板创建拼贴时,选择基于模板的拼贴后,当我点击按钮选择图像时,它从照片中选择图像并再次单击该按钮后打开照片库但我想在选择一次照片后再按钮动作是禁用... 所以帮我解决我的问题
`
- (IBAction)choosepic:(id)sender {
UIAlertView *alert1=[[UIAlertView alloc]initWithTitle:@"Select Image from..." message:@"" delegate:self cancelButtonTitle:@"Image Gallary" otherButtonTitles:@"cancel", nil];
alert1.alertViewStyle=UIAlertViewStyleDefault;
alert1.tag=1;
[alert1 show];
[alert1 release];
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (alertView.tag==1)
{
if(buttonIndex == 0)
imagepicker=[[UIImagePickerController alloc]init];
imagepicker.delegate=self;
imagepicker.sourceType=UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:imagepicker animated:YES];
}
}
-(IBAction)imagepickMethod1:(id)sender
{
imagepicker=[[UIImagePickerController alloc]init];
imagepicker.delegate=self;
imagepicker.sourceType=UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:imagepicker animated:YES];
button1.tag=100;
}
-(IBAction)imagepickMethod2:(id)sender
{
imagepicker=[[UIImagePickerController alloc]init];
imagepicker.delegate=self;
imagepicker.sourceType=UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:imagepicker animated:YES];
button1.tag=101;
}
-(IBAction)imagepickMethod3:(id)sender
{
imagepicker=[[UIImagePickerController alloc]init];
imagepicker.delegate=self;
imagepicker.sourceType=UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:imagepicker animated:YES];
button1.tag=102;
}
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo
{
[picker dismissModalViewControllerAnimated:YES];
if (button1.tag==100)
{
photoPreviewImageView1.image=image;
}
else
if (button1.tag==101)
{
photoPreviewImageView2.image=image;
}
else
{
photoPreviewImageView3.image=image;
}
}
`
答案 0 :(得分:1)
您可以在
中使用此功能- (IBAction)choosepic:(id)sender:
{
UIButton *btn = sender;
btn.enabled = FALSE;
}
答案 1 :(得分:1)
您可以通过将userInteractionEnabled
属性值设置为NO
来禁用该按钮上的用户互动。
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo
{
picker dismissModalViewControllerAnimated:YES];
if (button1.tag==100)
{
photoPreviewImageView1.image=image;
[button1 setUserInteractionEnabled:NO];
}
else if (button1.tag==101)
{
photoPreviewImageView2.image=image;
}
else
{
photoPreviewImageView3.image=image;
}
}