我是objective-c的新手,並且已經連續數週陷入這個問題。所以,將不勝感激任何幫助。無法在現有的UIWebView中顯示新頁面
我正在開發一個具有選項卡視圖的I-phone應用程序,其中一個選項卡是UIWebView。另一個選項卡提供了一種方法來選擇應在UIWebView中顯示的內容。
我可以顯示在UIWebView中(在viewDidLoad中)與初始視圖:
[self.groupWebView loadHTMLString:html baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]];
即工作得很好。
但是,當用戶在表視圖上選擇一些內容時,它必須在現有的UIWebView中打開一個新頁面。
所以我有這樣的:
-(void) displayGroup:(int)theGroup
{
// Set our selves to the webviews delegate since we implement the delegate methods here
self.groupWebView.delegate = self;
// Load it to the webview
NSString *html = @"<html><head><title>it worked...</title></head><body><a href=\"custom://THIS_IS_CUSTOM_LINK\">Click for custom link</a><br><a href=\"http://google.com\">it worked...</a></body></html>";
[self.groupWebView loadHTMLString:html baseURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] bundlePath]]];
}
我把這個和它的運行,但什麼也沒有發生在Web視圖。
.h文件看起來像:
// PBGroupViewController.h
#import <UIKit/UIKit.h>
@interface PBGroupViewController : UIViewController <UIWebViewDelegate, UIScrollViewDelegate>
@property (nonatomic, retain) IBOutlet UIWebView *groupWebView;
- (void) displayGroup:(int)theGroup;
@end
任何幫助就這將是非常不勝感激...謝謝。
確認您的webView不是無 – Misha
webView正在顯示初始頁面,因此我認爲它不是無用的。但我不認爲這個函數displayGroup實際上是連接到webView。我對此很陌生,錯過了一些我認爲的東西。也許displayGroup函數應該將webView作爲函數的參數之一?我不知道...但我認爲我沒有連接到webView ... – madhu