XCODE dynamically generated BUTTON
CGRect frame = CGRectMake (90, 200, 200, 60);
UIButton * someAddButton = [UIButton buttonWithType: UIButtonTypeRoundedRect];
someAddButton.backgroundColor = [UIColor clearColor];
[SomeAddButton setTitle: @ "dynamically add a button!" ForState: UIControlStateNormal];
someAddButton.frame = frame;
[SomeAddButton addTarget: self action: @ selector (someButtonClicked) forControlEvents: UIControlEventTouchUpInside];
Then I need to delete this BUTTON how to handle it?
Reply:
Furthermore, the increase click event
- (Void) someButtonClicked {
UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @ "prompt"
message: @ "You clicked on the dynamic button!"
delegate: self
cancelButtonTitle: @ "OK"
otherButtonTitles: @ "Cancel", @ "third", nil];
NSLog (@ "someButtonClicked");
[Alert show];
}
How do I know chose Which ah?
Reply:
1, give this button to set a tag, such as someAddButton.tag = 999; want to delete this tag to find through the button (self viewWithTag :) after remove it.
2, as judged by tag
Reply:
By tag get to the button object, and then removeFromSuperview
No comments:
Post a Comment