Dranix
Dranix

Reputation: 551

iPhone - webViewDidFinishLoad is not called

I have an IB that contant an UIWebView

#import <UIKit/UIKit.h>

@interface PostFunHorosViewController : UIViewController<UIWebViewDelegate>{

}

@property (nonatomic, retain) IBOutlet UIWebView *description;
@end

And at ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];

    description.delegate = self;
    [self.description loadHTMLString:[NSString stringWithFormat:@"<div align='justify'>%@<div>",[@"This is test string" stringByReplacingOccurrencesOfString: @"\n" withString:@"<br/>"]] baseURL:nil];
}

- (void)webViewDidFinishLoad:(UIWebView *)webView {
    NSLog(@"webViewDidFinishLoad");
}
- (void)webViewDidStartLoad:(UIWebView *)webView
{
    NSLog(@"webViewDidStartLoad");
}

And this is how I add IB to my screen:

- (void)viewDidLoad
{   
    PostFunHorosViewController *postVC = [[PostFunHorosViewController alloc] initWithNibName:@"PostFunHorosViewController" bundle:nil];
    [scroller addSubview:postVC.view];                   
    [postVC release];                
    [super viewDidLoad];
}

My problem is it never call webViewDidFinishLoad and webViewDidStartLoad.
Moreover it also stuck in

int main(int argc, char *argv[])
{
    @autoreleasepool {
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([IHOROSAppDelegate class]));
    }
}

with no exception.

Am I miss something. Please help me. Thank in advance.

Upvotes: 0

Views: 3741

Answers (2)

Shivbaba&#39;s son
Shivbaba&#39;s son

Reputation: 1369

Instead taking the delegate programatically try to taking the outlet as you have XIB file. One morething I would suggest to print like this,

description.delegate=self;
NSLog(@"Self %@",self);

So, you would have clear idea where you are setting the delegates.

Upvotes: 0

rishi
rishi

Reputation: 11839

Use -

self.description.delegate = self;  (in viewDidLoad)

earlier you are doing -

description.delegate = self;

while you haven't define instance variable, instead you have defined property.

Upvotes: 1

Related Questions