ios - Using two view controllers, second one won't display views -
for reason i'm having trouble displaying view secondary view controller in application.
main view controller calls view controller that's responsible loading pdf view.
the code in mainviewcontroller looks this:
- (int)openpdf { [self loadsettingswithdefaults]; rdpdfviewcontroller *m_pdf; if( m_pdf == nil ) { m_pdf = [[rdpdfviewcontroller alloc] initwithnibname:@"rdpdfviewcontroller"bundle:nil]; } int result = [m_pdf pdfopen:@"/users/steve/test.pdf" withpassword:@""]; if(result == 1) { m_pdf.hidesbottombarwhenpushed = yes; [self.navigationcontroller pushviewcontroller:m_pdf animated:yes]; } return result; }
this code located in second view. method referred above in mainviewcontroller.
- (int)pdfopen:(nsstring *)path withpassword:(nsstring *)pwd { [self pdfclose]; pdf_err err = 0; m_doc = [[pdfdoc alloc] init]; err = [m_doc open:path :pwd]; switch( err ) { case err_ok: break; case err_password: return 2; break; default: return 0; } cgrect rect = [[uiscreen mainscreen]bounds]; //gear if (![self isportrait] && rect.size.width < rect.size.height) { float height = rect.size.height; rect.size.height = rect.size.width; rect.size.width = height; } //end if(sys_version>=7.0) { m_view = [[pdfview alloc] initwithframe:cgrectmake(0, 0, rect.size.width, rect.size.height)]; } else { m_view = [[pdfview alloc] initwithframe:cgrectmake(0, 0, rect.size.width, rect.size.height-20-44)]; } [m_view vopen :m_doc :(id<pdfviewdelegate>)self]; pagecount = [m_doc pagecount]; [self.view addsubview:m_view]; return 1; }
when code executes, know view object being created can see debug output coming in console. not display new view in iphone simulator.
feel free provide feedback--just remember first stackoverflow post! i'll happy provide more info needed.
my main view controller set root view controller application. had set navigation controller root view controller, , add other view controllers after that.
after told navcontroller pop root view controller.
navcontroller = [[uinavigationcontroller alloc] initwithrootviewcontroller:mainviewcontroller]; self.window.rootviewcontroller = navcontroller; [self.window makekeyandvisible]; [navcontroller setnavigationbarhidden:yes]; [navcontroller poptorootviewcontrolleranimated:yes];
Comments
Post a Comment