【问题标题】:trying to make tabbed uiwebview browser need help xcode试图制作标签式uiwebview浏览器需要帮助xcode
【发布时间】:2013-02-12 15:59:49
【问题描述】:

我正在尝试制作标签浏览器,就像带有标签的 safari 或 chrome 一样。 当用户打开新的 url 时,webview 将被添加到数组中。当用户点击按钮然后 openLoadedWebview: 将调用并删除原始 webview 并从数组中打开加载的 webview。

但这并没有发生。工作是: webview removefromsuperview 有效。 wv 成功添加到 self.view。带索引号 问题: 新添加的 wv 与具有相同 url 的 webview 相同。

任何更好的想法或方法...我是全新的...

ma​​inViewController.h

 @interface mainViewController : UIViewController <UITextFieldDelegate, UIWebViewDelegate>
    {
        UIWebView *webView;
        UIWebView *wv;
    }
    @property (nonatomic, strong) NSMutableArray *array;

ma​​inViewController.m

- (void)viewDidLoad
{
    [super viewDidLoad];
    webView = [[UIWebView alloc]init];
    webView.frame = CGRectMake(10, 130, 300, 400);
    webView.delegate = self;
    [self.view addSubview:webView];
}


-(BOOL)textFieldShouldReturn:(UITextField *)textField {


    textField.text = [self repairURL:textField.text];
    NSURL *url = [[NSURL alloc] initWithString:textField.text];
    NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url];
    [webView loadRequest:request];
    [array addObject:webView];

    return true;
}

-(void)openLoadedWebview:(NSString *)pageLabel

    if ([cell.label.text isEqualToString:@"Trending"]) {
                NSLog(@"Selected Cell: %@", pageLabel);
            NSLog(@"number of objects %d", [array count]);
           // wv = [[UIWebView alloc]init];

            wv = [array objectAtIndex:0];
            wv.frame = CGRectMake(10, 100, 300, 400);
            wv.delegate = self;
            [self.view addSubview:wv];


        }
      else if ([cell.label.text isEqualToString:@"Rec"]) {

            wv = [array objectAtIndex:1];
            wv.frame = CGRectMake(10, 100, 300, 400);
            wv.delegate = self;
            [self.view addSubview:wv];
        }

[webView removeFromSuperview];
}

【问题讨论】:

    标签: objective-c xcode uiwebview


    【解决方案1】:

    您可以使用以下之一: https://github.com/graetzer/SGTabs https://github.com/xxhp/BrowserTabViewDemo

    我认为这就是您想要实现的目标:https://github.com/fictorial/BHTabBar

    【讨论】:

    • 非常感谢它帮助了我很多...还有一个问题我如何使用代码手动加载/带到前面或删除任何选项卡。?在 SGTabs 代码中。
    • 另外请告诉我我可以在我的应用程序中使用 SGTabs 吗?免费应用还是付费应用?
    • 安装详情请参考GitHub页面的README.md
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-07
    • 1970-01-01
    • 1970-01-01
    • 2015-09-04
    相关资源
    最近更新 更多