I am new to IOS programming. I am starting from the basic application created by XCode 4.3 (SingleView application).
Continuing from my above question, I was able to add Views programmaticaly to the main ViewController in the Appdelegate but If I want to do the same after the view has loaded (inside viewDidLoad), I am facing the trouble. I tried using the same logic of adding subviews but I am not sure if the view needs a refresh after adding inside ‘viewDidLoad’
My views are very simple, here is the code
-(void)viewDidLoad
{
[super viewDidLoad];
UIBUtton *btn = [UIBUtton] alloc] initWithFrame:CGRect(10,10,50,50)];
[self.view addSubView:btn];
[self.view setNeedsDsiplay];
}
Can someone please help?
You are not instantiating the
UIButtoncorrectly. You should usebuttonWithType:method.For example: