swift – button.setImage(nil, for: .regular) not working in iOS 15

0
55

[ad_1]

I used to be attempting to make a easy tic-tac-toe app in Swift, so I arrange 9 buttons with tags from 1 to 9 and name setImage to set noughts or crosses. That is working as supposed.

The issue comes when attempting to reset the board, the place I name this piece of code:

for i in 1..<10 {
    if let button = view.viewWithTag(i) as? UIButton {
        button.setImage(nil, for: .regular)
    }
}

This could take away the picture from the button, however it does nothing. The button is ready to Customized within the storyboard, and the tags are certainly assigned as they need to. I additionally tried getting an outlet for one of many buttons and calling setImage(nil, for: .regular) in that one and it did not work both.

I even created a brand new mission with only a button the place I name setImage, and it’s certainly working for non-nil pictures however not with nil as worth.

Has Apple modified the way in which of eradicating pictures? One other query(When button pressed, button.setImage(nil) does not work) appears to have the identical drawback, but when I work with isHidden I can now not click on on the buttons, and it shouldn’t be the workaround, seems very hacky to me.

Is that this a bug on iOS? Did the implementation change or one thing?

Thanks.

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here