Search code examples
iosswiftuiactionsheet

Re-Enable Action Sheet Action


I have a func that displays a couple of actionSheet Actions to set an image and to remove one. I have created an if statement where it disables the remove Action when there is a default image. I am trying to enable it now whenever there is anything else that goes in other than a default image.

 if let emptyImage = UIImage(named: "Default_Image") {


        if emptyImage == UIImage(named: "Default_Image") {

            RemoveAction.isEnabled = false
        }else{
            RemoveAction.isEnabled = true

        }
    }

My else statement is where i'm having issues as i'm not sure what to give in the else to make it enabled for any image coming in. I tried to add a UIImagePickerController by the else but it was giving errors.

I'm adding this if statement at the end of my action sheet list.

I am still fairly new to swift but also if there is a better way to call the action sheet actions or to disable them i would like to hear. Thanks!


Solution

  • I found that the image that was being removed was going to reopen when you pressed the Remove button so i just removed the 'Remove' ActionSheet action from the list as i didn't need it