When I tried creating a UIButton programmatically, it at first did not respond to clicks. This was even after I had added a callback for the button, as below:
[exitButton addTarget:self action:@selector(exitButtonPressed) forControlEvents:UIControlEventTouchUpInside];
After some troubleshooting, I found the source of the problem. It was because the size of the button was not defined. Once the size was defined, the button became responsive to clicks.
CGRect exitButtonFrame = exitButton.frame;
exitButtonFrame.size.width = 32;
exitButtonFrame.size.height = 32;
exitButtonView.frame = exitButtonFrame;
No comments:
Post a Comment