Reputation: 15
I have a TabViewController. It consists of several views. For a particular view I want to add some buttons dynamically at runtime. The view already have some controls which has been created using Interface Builder.
Upvotes: 0
Views: 1665
Reputation: 5737
You can add controls like this:
// create new control
var control = new UIView(); // or UIButton, etc.
// set control props ..
control.Hidden = false;
control.Frame = x // = Bounds
// ...
// add control to parent
window.AddSubview(control);
Upvotes: 1
Reputation: 22726
just sample code for UIButton
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget:self action:@selector(aMethod:) forControlEvents:UIControlEventTouchDown];
[button setTitle:@"Show View" forState:UIControlStateNormal];
button.frame = CGRectMake(80.0, 210.0, 160.0, 40.0);
[yourView addSubview:button];
Here you can set Button Type/Controlling Event/Title etc as per your requirement.
Hope this helps.
Upvotes: 0