IOS Dynamic Join button

Source: Internet
Author: User

Press the existing button to create a new button yourself and add the event for the new button, so when you click the pop-up prompt box.

Add to Viewcontroller.h

@property (weak, nonatomic) iboutletUIButton *addbutton;

Add a response event to this button AddButton

Join in the VIEWCONTROLLER.M

-(ibaction) AddButton: (ID) Sender {

// dynamically add a button

CGRect frame = cgrectmake(0,0, +) ;

UIButton *button = [UIButtonbuttonwithtype: Uibuttontyperoundedrect];

button. frame = frame;

[Button settitle:@ " new Dynamic button added "forstate: UIControlStateNormal];

button. BackgroundColor = [uicolor RedColor];

button. tag =+;

[Button addTarget:self action:@selector(buttonclicked :)forcontrolevents:uicontroleventtouchupinside];

[Self. View addsubview: button];

}

// This is the response function of the new button

-(ibaction) buttonclicked: (ID) Sender {

    uialertview *alert = [[ uialertview< Span style= "COLOR: #000000" > alloc ] Span style= "COLOR: #3d1d81" >initwithtitle : @ " hint "

message:@ " click on Dynamic button!

"

delegate: Self

cancelbuttontitle:@ " OK "

otherbuttontitles:nil];

[Alertshow];

}



Copyright notice: This article Bo Master original article. Blog, not reproduced without consent.

IOS Dynamic Join button

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.