Three20 不在 UIWebView 中显示网站

发布于 2024-10-25 19:36:40 字数 1137 浏览 2 评论 0原文

大家好 我有一个基于选项卡栏的应用程序。在一个视图中,我有一个带有不同 TTTabItems 的 TTTabStrip。除了加载 UIWebView 之外,一切正常(加载正常的 UIViewController)。

在应用程序委托中,我设置了 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?

多谢。

Hi all
I have a tabbar based application. In one view I have a TTTabStrip with different TTTabItems. Everything works (loading normal UIViewControllers) except loading UIWebViews.

In the app delegate I have set up the url mapping:

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]];

The test controller contains one UIWebView. I can see (NSLog) that the loadView-Method gets called, but the URL is not being opened:

- (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;
}

For instance, I can change the background of the UIWebView to black.

How can I load google in the web view below the TTTabStrip?

Thanks a lot.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

花桑 2024-11-01 19:36:40

尝试以下操作并添加方法 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]]; 
}

Try the following and add the method 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]]; 
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文