Three20没有在UIWebView中显示网站

时间:2011-03-22 15:44:00

标签: iphone objective-c uiwebview three20

大家好 我有一个基于tabbar的应用程序。在一个视图中,我有一个TTTabStrip与不同的TTTabItems。一切正常(加载普通的UIViewControllers),除了加载UIWebViews。

在app委托中,我设置了url映射:

TTNavigator* navigator = [TTNavigator navigator];
navigator.supportsShakeToReload = YES;
navigator.persistenceMode = TTNavigatorPersistenceModeAll;

TTURLMap* map = navigator.URLMap;
[map from:@"*" toViewController:[TTWebController class]]; // default klasse wenn nichts anderes gewählt ist.
[map from:@"tt://test" toViewController:[TestController class]];

测试控制器包含一个UIWebView。我可以看到(NSLog)调用loadView-Method,但是没有打开URL:

- (void) loadView {

    CGRect applicationFrame = [UIScreen mainScreen].applicationFrame;
    self.view = [[[UIView alloc] initWithFrame:applicationFrame] autorelease];
    //self.view.backgroundColor = [UIColor blackColor];

    NSURL *theURL = [NSURL URLWithString:@"http://www.google.com"];
    [webView loadRequest:[NSURLRequest requestWithURL:theURL]]; 

    // support zooming
    webView.scalesPageToFit = YES;
}

例如,我可以将UIWebView的背景更改为黑色。

如何在TTTabStrip下方的网络视图中加载Google?

非常感谢。

1 个答案:

答案 0 :(得分:3)

尝试以下操作并添加方法viewWillAppear:

- (void)loadView 
{
    CGRect applicationFrame = [UIScreen mainScreen].applicationFrame;
    UIView * newView = [[UIView alloc] initWithFrame:applicationFrame];

    // support zooming
    webView.scalesPageToFit = YES;

    [newView addSubview:webView];

    self.view = newView;
    [newView release];
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];

    NSURL *theURL = [NSURL URLWithString:@"http://www.google.com"];
    [webView loadRequest:[NSURLRequest requestWithURL:theURL]]; 
}