objective c - IPhone: How to Switch Between Subviews That Were Created in Interface Builder -


so have 2 subviews within main view. created each subview going library in ib , dragging view onto main nib file , positioning controls on them.

now, i'd flip between these views via "flip" button. don't understand how can programmatically this.

my question is: "hide" 1 of subviews , unhide someway programmatically when flip? give each name via interface builder , way? don't need code flip or anything, need conceptual understanding of how i'd refer views built in ib programmatically , if hiding makes sense in scenerio...

any suggestions? thanks

you connect things in ib using
iboutlet uiview *myview;
or
@property (nonatomic, retain) iboutlet uiview *myview;
in header file. iboutlet keyword tells ib make outlet available connect.

you make actual connection in connection inspector dragging outlet view: making connection http://cl.ly/eb3b5cd826b20fc9e307/content

(do both views.)

note: views don't have inside window in ib. can create them outside, , won't displayed until want them to. might want put 1 of them in shows when app launches.

then, when want flip other view, assuming you're using ios 4.0, it's simple (there methods 3.x , lower, easiest):

[uiview transitionfromview:myview1                     toview:myview2                   duration:0.2                    options:uiviewanimationoptiontransitionflipfromright                 completion:^{                     // when flip completes                 }]; 

or, if want dynamically determine view visible:

uiview *oldview, *newview; uiviewanimationoptions transition; if (myview1.superview) { // view 1 visible     oldview = myview1;     newview = myview2;     transition = uiviewanimationoptiontransitionflipfromright; } else { // view 2 visible     oldview = myview2;     newview = myview1;     transition = uiviewanimationoptiontransitionflipfromleft; } [uiview transitionfromview:oldview                     toview:newview                   duration:0.2                    options:transition                 completion:^{                     // when flip completes                 }]; 

Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -