iphone - Why is my UINavigation controller off by 79 pixels -
in iphone works great.
however when @ navigationbar frame -44? iphone y origin 0.
is supposed this? seems shifted 79 pixels.
any idea how fix?
when rotate sizes ok initial landscape size wrong.
adding view code fixes not want do: navigationcontroller.view.superview.frame = cgrectmake(-79, 0, size.width, size.height);
startravelappdelegate *appdelegate = (startravelappdelegate *) [[uiapplication sharedapplication] delegate]; firstmenuview *firstmenuview = [[[firstmenuview alloc] init] autorelease]; // bac123viewcontroller *bac123 = [[bac123viewcontroller alloc] autorelease]; // uinavigationcontroller *navigationcontroller; // appdelegate.navcontroller = [[[uinavigationcontroller alloc] initwithrootviewcontroller:firstmenuview] autorelease]; mynavigationcontroller *navigationcontroller = appdelegate.navcontroller; [navigationcontroller pushviewcontroller:firstmenuview animated:true]; cgsize size = [[ccdirector shareddirector] winsize]; navigationcontroller.view.superview.frame = cgrectmake(-79, 0, size.width, size.height); // uiview *view = [[ccdirector shareddirector] view]; // [view addsubview:bac123.view]; // [view addsubview:navigationcontroller.view]; navigationcontroller.navigationbarhidden = true;
the app delegate:
@implementation mynavigationcontroller // available orientations should defined in info.plist file. // , in ios 6+ only, can override in root view controller in "supportedinterfaceorientations" method. // valid ios 6+. not valid ios 4 / 5. -(nsuinteger)supportedinterfaceorientations { // iphone if( [[uidevice currentdevice] userinterfaceidiom] == uiuserinterfaceidiomphone ) return uiinterfaceorientationmasklandscape; // ipad return uiinterfaceorientationmasklandscape; } // supported orientations. customize own needs // valid on ios 4 / 5. not valid ios 6. - (bool)shouldautorotatetointerfaceorientation:(uiinterfaceorientation)interfaceorientation { // iphone if( [[uidevice currentdevice] userinterfaceidiom] == uiuserinterfaceidiomphone ) return uiinterfaceorientationislandscape(interfaceorientation); // ipad // iphone return uiinterfaceorientationislandscape(interfaceorientation); } // needed ios4 , ios5 in order ensure // 1st scene has correct dimensions // not needed on ios6 , added application:didfinish... -(void) directordidreshapeprojection:(ccdirector*)director { if(director.runningscene == nil) { // add first scene stack. director draw framebuffer. (animation started automatically when view displayed.) // , add scene stack. director run when automatically when view displayed. [director runwithscene: [spacescene scene]]; } } @end @implementation startravelappdelegate @synthesize window=window_, navcontroller=navcontroller_, director=director_; - (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions { // create main window window_ = [[uiwindow alloc] initwithframe:[[uiscreen mainscreen] bounds]]; // ccglview creation // viewwithframe: size of opengl view. full screen use [_window bounds] // - possible values: cgrect // pixelformat: format of render buffer. use rgba8 better color precision (eg: gradients). takes more memory , slower // - possible values: keaglcolorformatrgba8, keaglcolorformatrgb565 // depthformat: use stencil if plan use ccclippingnode. use depth if plan use 3d effects, cccamera or ccnode#vertexz // - possible values: 0, gl_depth_component24_oes, gl_depth24_stencil8_oes // sharegroup: opengl sharegroup. useful if want share same opengl context between different threads // - possible values: nil, or valid eaglsharegroup group // multisampling: whether or not enable multisampling // - possible values: yes, no // numberofsamples: valid if multisampling enabled // - possible values: 0 glgetintegerv(gl_max_samples_apple) ccglview *glview = [ccglview viewwithframe:[window_ bounds] pixelformat:keaglcolorformatrgb565 depthformat:0 preservebackbuffer:no sharegroup:nil multisampling:no numberofsamples:0]; director_ = (ccdirectorios*) [ccdirector shareddirector]; director_.wantsfullscreenlayout = yes; // display fsp , spf [director_ setdisplaystats:yes]; // set fps @ 60 [director_ setanimationinterval:1.0/60]; // attach openglview director [director_ setview:glview]; // 2d projection [director_ setprojection:kccdirectorprojection2d]; // [director setprojection:kccdirectorprojection3d]; // enables high res mode (retina display) on iphone 4 , maintains low res on other devices if( ! [director_ enableretinadisplay:yes] ) cclog(@"retina display not supported"); // default texture format png/bmp/tiff/jpeg/gif images // can rgba8888, rgba4444, rgb5_a1, rgb565 // can change setting @ time. [cctexture2d setdefaultalphapixelformat:kcctexture2dpixelformat_rgba8888]; // if 1st suffix not found , if fallback enabled fallback suffixes going searched. if none found, try name without suffix. // on ipad hd : "-ipadhd", "-ipad", "-hd" // on ipad : "-ipad", "-hd" // on iphone hd: "-hd" ccfileutils *sharedfileutils = [ccfileutils sharedfileutils]; [sharedfileutils setenablefallbacksuffixes:no]; // default: no. no fallback suffixes going used [sharedfileutils setiphoneretinadisplaysuffix:@"-hd"]; // default on iphone retinadisplay "-hd" [sharedfileutils setipadsuffix:@"-ipad"]; // default on ipad "ipad" [sharedfileutils setipadretinadisplaysuffix:@"-ipadhd"]; // default on ipad retinadisplay "-ipadhd" // assume pvr images have premultiplied alpha [cctexture2d pvrimageshavepremultipliedalpha:yes]; // create navigation controller director navcontroller_ = [[mynavigationcontroller alloc] initwithrootviewcontroller:director_]; navcontroller_.navigationbarhidden = yes; // rotation , other messages [director_ setdelegate:navcontroller_]; // set navigation controller root view controller [window_ setrootviewcontroller:navcontroller_]; //[window_ addsubview: navcontroller_.view]; // make main window visible [window_ makekeyandvisible]; return yes; } // getting call, pause game -(void) applicationwillresignactive:(uiapplication *)application { if( [navcontroller_ visibleviewcontroller] == director_ ) [director_ pause]; } // call got rejected -(void) applicationdidbecomeactive:(uiapplication *)application { [[ccdirector shareddirector] setnextdeltatimezero:yes]; if( [navcontroller_ visibleviewcontroller] == director_ ) [director_ resume]; } -(void) applicationdidenterbackground:(uiapplication*)application { if( [navcontroller_ visibleviewcontroller] == director_ ) [director_ stopanimation]; } -(void) applicationwillenterforeground:(uiapplication*)application { if( [navcontroller_ visibleviewcontroller] == director_ ) [director_ startanimation]; } // application killed - (void)applicationwillterminate:(uiapplication *)application { cc_director_end(); } // purge memory - (void)applicationdidreceivememorywarning:(uiapplication *)application { [[ccdirector shareddirector] purgecacheddata]; } // next delta time 0 -(void) applicationsignificanttimechange:(uiapplication *)application { [[ccdirector shareddirector] setnextdeltatimezero:yes]; } - (void) dealloc { [window_ release]; [navcontroller_ release]; [super dealloc]; } @end
Comments
Post a Comment