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 venture with only a button the place I name setImage, and it’s certainly working for non-nil photos however not with nil as worth.

Has Apple modified the way in which of eradicating photos? One other query(When button pressed, button.setImage(nil) does not work) appears to have the identical downside, but when I work with isHidden I can 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?


By admin

Leave a Reply

Your email address will not be published.