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 @ ...

http://developer.apple.com/library/ios/#documentation/cocoa/conceptual/objectivec/articles/ocallocinit.html%23//apple_ref/doc/uid/tp30001163-ch22-105377

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

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -