调用webViewDidFinishLoad

调用webViewDidFinishLoad

我有一个与UIWebView竞争的IB

#import <UIKit/UIKit.h>

@interface PostFunHorosViewController : UIViewController<UIWebViewDelegate>{

}

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


然后在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");
}


这就是我将IB添加到屏幕的方式:

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


我的问题是永远不要调用webViewDidFinishLoad和webViewDidStartLoad。
而且它也卡在

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


毫无例外。

我想念什么吗?请帮我。预先感谢。

最佳答案

采用 -

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


您之前在做-

description.delegate = self;


虽然您没有定义实例变量,但您已经定义了属性。

关于iphone - iPhone-未调用webViewDidFinishLoad,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/10221616/

10-12 03:38