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