objective c - Placing a subview on another view -
have loaded view xib file on window(another xib) dynamically subview.
understand default subview loaded in first quadrant of window i.e.,the subview @ extreme left bottom of window. same case window well.
issue how place subview elsewhere on window. in other words, if want place subview on top of window, how achieve it??
also appreciate if can explanation nsrect , frame nswindow objects..
if there methods in of apis, please direct me them.. in advance...
update:
@interface viewavailableitemswindowcontroller : nsobject { iboutlet nswindow * viewavailableitemswindow; //window in question iboutlet nsview * viewavailableitemsview; //view in question itemsearchviewcontroller * instanceitemsearchview; //viewcontroller object } @end @implementation viewavailableitemswindowcontroller -(void)awakefromnib{ [viewavailableitemswindow makekeyandorderfront:nil]; instanceitemsearchview = [[itemsearchviewcontroller alloc]initwithnibname:@"itemsearchview" bundle:nil] ; //initiating viewcontroller nib view. [viewavailableitemsview addsubview:[instanceitemsearchview view]]; //adding subview window.. } -(void)dealloc{ [instanceitemsearchview release]; [super dealloc]; } @end
this loads view on first quadrant of window- mean bottom left corner of window. want view placed on top center of window.
an nsrect rectangle. it's composed of origin , size. origin point, x , y. size width , height. on i'll type rects {{x, y}, {width, height}}
each view has frame. frame of view position of view within superview. each view has bounds. bounds of view defines internal coordinate system of view. default 0, 0 in lower left corner, , x , y increase move right , up.
example: if 1 view had bounds of {{0, 0}, {100, 100}}, , put view inside of view , set frame {{25, 50}, {10, 10}} subview have size 10x10, , position 25 points right of left edge, , 50 points bottom.
the bounds size same frame size. typically not set or adjust bounds of view unless intend scale or shift of subviews , custom drawing - advanced thing do.
so if had this:
+-------------------+ | +----------+ | | | +---+ | | | | b | c | | | | | +---+ | | | +----------+ | | | | | +-------------------+
where each box represents nsview, , each view subview of next. contains b, contains c. bounds , frames of each of views might this:
bounds frame {{x, y}, {w, h}} {{ x, y}, {w, h}} {{0, 0}, {30, 30}} {{ 0, 0}, {30, 30}} b {{0, 0}, {20, 15}} {{20, 20}, {20, 15}} c {{0, 0}, {10, 10}} {{10, 10}, {10, 10}}
Comments
Post a Comment