objective c - load webview content in the initializer -
this ipad app. press 1 of 2 buttons , presents modal view controller containing webview display pdf. created uiviewcontroller class containing webview, , want use 1 of 2 initializers depending on button user pushes. when initialize object want set pdf displayed. modal view coming blank(no pdf displayed). however, when use same code within -(void)viewdidload{} work. why this? thanks!
- (id)initaspi{ nslog(@"initaspi called"); [super init]; nsstring *urladdress = [[nsbundle mainbundle] pathforresource:@"pipdf" oftype:@"pdf"]; nsurl *url = [nsurl fileurlwithpath:urladdress]; nsurlrequest *urlrequestobj = [nsurlrequest requestwithurl:url]; [prescribinginfowebview loadrequest:urlrequestobj]; return self; }
initialization
your initialization method wrong. read implementing initializer - handling initialization failure @ ...
it should ...
- (id)initaspi { self = [super init]; if ( self ) { // initialization code } return self; }
why work in viewdidload , not in initaspi?
prescribinginfowebview nil unless you're doing obscure elsewhere.
you're creating prescribinginfowebview in loadview method or automatically initialized during view load if you're loading view xib.
Comments
Post a Comment