i attempt to generate a new button item once i click on a button generator, it able to generate but only will show up on the screen after relaunch the application,but i want it be generated instantly and show up at the current view,any suggestion i know is something related to the viewDidLoad function,anyway pls help
views:
80answers:
3Lets say this is your view controller method that creates buttons:
-(void)generateButton:(id)sender {
UIButton *button = [UIbutton alloc] initWithFrame:CGRectMake(50, 50, 100, 40)];
[self.view addSubview:button];
[button release];
}
In order to be visible you have to add the button as a subview of a current showing view. In this case I am adding it to the main root level view for this view controller.
thanks Squeengy but i think u are not really understand my question i have generated the button successfully but it will only appear when i relaunch the application(exit the current application and relaunch),i want it can be appear when i click on the button immediately
When you add a subview to a view, it should be displayed immediately. Most likely, you're doing something very wrong which is resulting in the view not displaying when it should. Another thing, how are the views only showing up next launch? It sounds like you are actually persisting them somehow, which could be adding to the trouble caused by whatever you're doing. If this were IRC, I'd suggest you paste some code, because without that, there's little way to know what you're actually doing that could be causing so much trouble.