PDA

View Full Version : Two sets of controls on same UIView




arnieterm
Sep 1, 2008, 08:43 AM
Hi
I have a UIView and 3 sets of controls that are to be shown on the same view (UIView).
Initially when the view is made visible, the first set of controls appears on it. By clicking a button on this set, I have to clear the first set of controls and add 2nd set of controls. Similar steps are needed for the 3rd set.
How can I clear the first set of controls and show 2nd one?
Using the property clearsContextBeforeDrawing[Yes/No] is not working for the view. Since it is the strict requirement from the client so I was left with no option but to use a single view and show all sets of controls there on
Any idea??



Jeremy1026
Sep 1, 2008, 11:24 AM
Hi
I have a UIView and 3 sets of controls that are to be shown on the same view (UIView).
Initially when the view is made visible, the first set of controls appears on it. By clicking a button on this set, I have to clear the first set of controls and add 2nd set of controls. Similar steps are needed for the 3rd set.
How can I clear the first set of controls and show 2nd one?
Using the property clearsContextBeforeDrawing[Yes/No] is not working for the view. Since it is the strict requirement from the client so I was left with no option but to use a single view and show all sets of controls there on
Any idea??

What are the controls? You can try having stuff you're not using hidden, then hide the stuff you no longer need and unhide the stuff you do need in order to 'change' views.

newControl.hidden = NO;
oldControl.hidden = YES;

arnieterm
Sep 1, 2008, 11:12 PM
By control set I mean to say labels, textfields, buttons.
I also make use of clearsContextbeforeDrawing property of the UIView but it is not working

mccannmarc
Sep 2, 2008, 09:52 AM
To be honest your client sounds like an idiot, why would anyone limit the amount of views you can use and hence make your job ten times harder???

Anyway it might be a stupid solution i dont know, but why dont you use a state machine? have 3 states for your app and render the current view based on the state. If speed isn't critical you could have a timer that checks a global state variable say twice a second and if the state has changed it forces a redraw using the new state's drawing code.