0

私はXCodeに比較的慣れておらず、写真のコラージュアプリに取り組んでいます。コラージュを作成するためにテンプルを選択した後、ボタンをクリックして画像を選択したときにテンプルベースのコラージュを選択した後、フォトギャラリーから画像を選択し、そのボタンをクリックした後再び写真ライブラリを開きますが、一度だけ写真を選択した後、ボタンのアクションを無効にしたいので、問題を解決するのを手伝ってください

`

     - (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;
    }

        }

`

4

2 に答える 2

1

これをあなたの

- (IBAction)choosepic:(id)sender:
{
    UIButton *btn = sender;
    btn.enabled = FALSE;
}
于 2012-06-13T12:24:33.813 に答える
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;
    }
}
于 2012-06-13T12:26:14.110 に答える