我有一个包含 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]));
}
}
无一异常(exception)。
我是不是错过了什么?请帮我。提前致谢。
最佳答案
使用 -
self.description.delegate = self; (in viewDidLoad)
您之前所做的 -
description.delegate = self;
虽然您还没有定义实例变量,但您已经定义了属性。
关于iPhone - 未调用 webViewDidFinishLoad,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10221616/