0
我正在研究接收我在UIWebView中显示的源的应用程序。 Feed中嵌入了我想在Safari中打开的链接,而不是WebView。我查看了其他几个在这里发布的问题。我不确定我错过了什么,但我认为这很简单。这里是我的.h和.m文件在Safari中的UIWebView中打开链接
#import @class BlogRss; @interface EnduranceDailyWorkoutViewController : UIViewController { IBOutlet UIWebView * descriptionTextView; BlogRss * currentlySelectedBlogItem; } @property (nonatomic, retain) UIWebView * descriptionTextView; @property (readwrite, retain) BlogRss * currentlySelectedBlogItem; @end
#import "EnduranceDailyWorkoutViewController.h"
#import "BlogRss.h"
@implementation EnduranceDailyWorkoutViewController
@synthesize descriptionTextView = descriptionTextView;
@synthesize currentlySelectedBlogItem = currentlySelectedBlogItem;
- (void)viewDidLoad {
[super viewDidLoad];
NSString *html = [NSString stringWithFormat:@"%@ %@",currentlySelectedBlogItem.title, currentlySelectedBlogItem.contentEncoded];
[descriptionTextView loadHTMLString:html baseURL:[NSURL URLWithString:nil]];
}
-(BOOL)webView:(UIWebView *)descriptionTextView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
if (UIWebViewNavigationTypeLinkClicked == navigationType) {
[[UIApplication sharedApplication] openURL:[request URL]];
return NO;
}
return YES;
}
使用Interface Builder我已经挂了IBOutlet中和UIWebView的。请让我知道我缺少什么。我在webView部分放置了断点,但代码从不碰到那里,所以它几乎就像在IB中没有正确链接。
GreginYEG,感谢您的帮助。我忘了设置代表。我以为我在Interface Builder中完成了这个工作,但显然不是。 – James 2011-03-21 09:51:02