I have programmatically generated a series of buttons in my app, and they work perfectly when they are pressed. Then I stored in memory the number of the buttons and, when I restart the app, the buttons are regenerated exactly as they were before, and yet they can't be pressed.
The method "deletebtn" prints "pressed" when the button is pressed, but it doesn't.
I've even tried to add to the properties of the programmatically generated button "buttonName.userInteractionEnabled = true", but nothing changes.
This are the properties of the button, and that's also the code I have on the viewdidload, that recreates as much buttons as the number of them that I have stored in memory:
let btn: UIButton = UIButton(frame: CGRectMake(10, CGFloat(60*a), ScreenWidth - 20 , 50))
btn.layer.cornerRadius = 0.5 * btn.bounds.size.height
btn.backgroundColor = UIColor.whiteColor()
btn.setTitleColor(UIColor.blackColor(), forState: .Normal)
btn.setTitle(ArrayService[(index)], forState: UIControlState.Normal)
btn.addTarget(self, action: Selector("deletebtn:"), forControlEvents: UIControlEvents.TouchUpInside)
btn.tag = a //an int variable that is increased each time i create a neew button
btn.userInteractionEnabled = true
I managed to solve it. It's pretty awkward actually: what happens it's just that when you restart the app the logs don't appear anymore.