how to set button noneditable

I'm relatively new to XCode and I m working on photo collage App , when i choose templete to create collage ,after choose templete based collage when i clicked on button to choose images thn it choose image from photo gallry and after clicking on that button again it open photo library but i want after choosing one time photo then the button action is disable... so help me to solve my problem

`

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

        }

`

Answers


You can disable user interaction on the button by setting userInteractionEnabled property value to 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;
    }
}

You can use this in your

- (IBAction)choosepic:(id)sender:
{
    UIButton *btn = sender;
    btn.enabled = FALSE;
}

Need Your Help

How can I get windows to remember my device after installing it so I don't get the new device message upon every connection?

windows drivers

I have a piece of hardware that we created that connects to my PC via USB. We also wrote the drivers for it. EVERY time I plug this device in, the new device message comes up, even though the dri...

Laravel error interface class does not exist

php laravel interface namespaces repository

I am very new to "Advanced Laravel" so to speak, however I do know most of the basics and I am trying to understand what namespacing, interfaces and repositories is all about, since I came across i...