uiimageview - Button hidden behind my BaseViewController in iPhone -
i facing weird problem. have baseviewcontroller extends uiviewcontroller. in baseview controller have custom headerbar (uiimageview) on top of it.
i made new viewcontroller , extends new viewcontroller baseviewcontroller. headerbar in baseviewcontroller appearing on uiviewcontroller. if add subview in newviewcontroller on headerbar not come on whereas goes behind header bar.
can suggest do.
edited
here code.
baseviewcontroller
- (id)initwithnibname:(nsstring *)nibnameornil bundle:(nsbundle *)nibbundleornil { cgfloat xoffset = 0; if (ui_user_interface_idiom() == uiuserinterfaceidiompad) { xoffset = 224; } self = [super initwithnibname:nibnameornil bundle:nibbundleornil]; if (self) { // custom initialization headerbarview = [self addheaderbar]; //[self.view addsubview:headerbarview]; [self.view insertsubview:headerbarview belowsubview:self.view]; } return self; } -(uiview *)addheaderbar{ uiview *header_bar = [[uiview alloc] initwithframe:cgrectmake(0.0, 0.0, 320, 50.0)]; //headerbar image uiimageview *headerbar = [[uiimageview alloc] initwithframe:cgrectmake(0, 0.0, 320, 50.0)]; [headerbar setimage:[uiimage imagenamed:@"top_bar"]]; [header_bar addsubview:headerbar]; return header_bar; }
newviewcontroller extended baseviewcontroller
//back button = [ui getactionbarbuttonwithname:[nsstring stringwithformat:@"back"] andcgrect:cgrectmake(7.0, 100.0, 55.0, 31.0) andedgeinset:uiedgeinsetsmake(0.0, 9.0, 2.0, 0.0) withbackground:[uiimage imagenamed:@"back_button"]]; [self.view bringsubviewtofront:back]; +(uibutton *)getactionbarbuttonwithname:(nsstring *)name andcgrect:(cgrect)rect andedgeinset:(uiedgeinsets)edgeinset withbackground:(uiimage *)background{ uibutton *button = [uibutton buttonwithtype:uibuttontypecustom]; button.frame = rect; [button setbackgroundimage:background forstate:uicontrolstatenormal]; [button settitleedgeinsets:edgeinset]; [button settitle:name forstate:uicontrolstatenormal]; [button.titlelabel setfont:[uifont boldsystemfontofsize:13.0]]; [button setuserinteractionenabled:yes]; return button; }
if having many views, can use 1 of these -
[self.view insertsubview:<#(uiview *)#> abovesubview:<#(uiview *)#>] [self.view insertsubview:<#(uiview *)#> atindex:<#(nsinteger)#>] [self.view insertsubview:<#(uiview *)#> belowsubview:<#(uiview *)#>]
hope you.
Comments
Post a Comment