For (Uiview * View In [Self. backgroundview subviews])
{
// [View removefromsuperview];
If ([[View superclass] description] isw.tostring: @" Uibutton " ])
{
Uibutton * BTN = (uibutton *) view;
BTN. titlelabel. Text = @" Dynamic title " ;
BTN. Center = BTN. superview. Center;
}
}
-(Ibaction) addbutton :( ID ) Sender {
Cgrect frame = cgrectmake ( 90 , 200 , 200 , 60 );
Uibutton * someaddbutton = [uibutton buttonwithtype: uibuttontyperoundedrect];
Someaddbutton. backgroundcolor = [uicolor clearcolor];
[Someaddbutton settitle: @" Add a button dynamically! " Forstate: uicontrolstatenormal];
Someaddbutton. Frame = frame;
[Someaddbutton addtarget: Self action: @ selector (somebuttonclicked) forcontrolevents: uicontroleventtouchupinside];
[Self. View addsubview: someaddbutton];
}
-( Void ) Somebuttonclicked {
Uialertview * Alert = [[uialertview alloc] initwithtitle: @" Prompt "
Message: @" You have clicked the dynamic button! "
Delegate : Self
Cancelbuttontitle: @" OK "
Otherbuttontitles: Nil];
[Alert show];
}