Ok, here's another question.
I am creating a UIView called ProgressView , which is a translucent view with an activity indicator and a progress indicator.
I want to be able to use this view in different view managers in my application, when necessary.
I know three different ways to do this (but I'm only interested in one):
1) Create the whole view programmatically, create and customize as needed. Donβt worry, I get this one.
2) Create a UIView in the interface builder, add the necessary objects and load it using a method similar to the one below. The problem is that we basically assume that the view is objectAtIndex: 0, because nowhere in the documentation did I find a reference to the order of the elements returned by the [[NSBundle mainBundle] loadNibName: .
NSArray *nibContents = [[NSBundle mainBundle] loadNibNamed:@"yournib" owner:self options:nil]; UIView *myView = [nibContents objectAtIndex:0]; myView.frame = CGRectMake(0,0,300,400);
3) Subclass UIViewController and let it control the view in accordance with normal. In this case, I would never push the view controller onto the stack, but only its main view:
ProgressViewController *vc = [[ProgressViewController alloc] initWithNibName:@"ProgressView" bundle:nil]; [vc.view setCenter:CGPointMake(self.view.center.x, self.view.center.y)]; [self.view addSubview:vc.view]; [vc release];
As far as I can tell, # 3 is the right way to do this (except programmatically), but I'm not quite sure that it is safe to free the ProgressView view controller, while the other kind of controller retains its main look (Does it feel like it will expire?) ?
What should I do in terms of memory management in this case, where and when should I release the ProgressView view controller?
Thanks in advance for your thoughts.
Greetings
Horn