Thursday, 15 April 2010

ios - barbuttonitem now showing up, presentmodalviewcontroller -



ios - barbuttonitem now showing up, presentmodalviewcontroller -

i have need show pdf files modally, when user clicks on buttons load pdf class , nowadays modally, need provide user ab utton on modalvc close or go added rightbarbuttonitem, prioblem not showing up? code load pdf

[self.pdfviewcontroller.view addsubview:pdfviewer]; uinavigationcontroller *navcontroller = [[uinavigationcontroller alloc] initwithrootviewcontroller:pdfviewcontroller]; self.navigationitem.rightbarbuttonitem = [[uibarbuttonitem alloc] initwithbarbuttonsystemitem:uibarbuttonsystemitemadd target:self action:@selector(shutdown)]; [self presentmodalviewcontroller:navcontroller animated:yes];

what doing wrong here?

you attaching bar button wrong viewcontroller. should belong viewcontroller within presented navigationcontroller. pdfviewcontroller.

additionally...

assuming self.pdfviewcontroller same object pdfviewcontroller, it's best if refer consistently presentmodalviewcontroller deprecated since @ to the lowest degree ios5.0, should using presentviewcontroller:animated:completion

so code should this

[self.pdfviewcontroller.view addsubview:pdfviewer]; uinavigationcontroller *navcontroller = [[uinavigationcontroller alloc] initwithrootviewcontroller:self.pdfviewcontroller]; self.pdfviewcontroller.navigationitem.rightbarbuttonitem = [[uibarbuttonitem alloc] initwithbarbuttonsystemitem:uibarbuttonsystemitemadd target:self action:@selector(shutdown)]; [self presentviewcontroller:navcontroller animated:yes completion:nil];

your shutdown method sent presenting viewcontroller, not presented pdfviewcontroller... that's need implement it.

ios xcode uiviewcontroller

No comments:

Post a Comment