2013-02-12 44 views
0

我试图让制表符浏览器就像safari或带标签的chrome。 当用户打开新的url时,webview会被添加到数组中。当用户点击按钮,然后openLoadedWebview:将调用并删除原来的web视图,并从数组中打开一个加载的webview。试图制作标签式uiwebview浏览器需要帮助xcode

但它没有发生。工作的东西是: webview removefromsuperview的作品。 wv成功添加到self.view。索引号为 问题: 新添加的wv与具有相同url的webview相同。

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

mainViewController.h

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

mainViewController.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]; 
} 

回答

3

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

我觉得这是你想要达到的目标:https://github.com/fictorial/BHTabBar

+0

谢谢你洙多它帮助我很多......还有一个问题,我怎么可以加载/带来正面或代码手动删除任何标签。?在SGTabs代码中。 – user777304 2013-02-12 20:42:08

+0

也请告诉我,我可以在我的应用程序用户SGTabs?免费的应用或付费应用? – user777304 2013-02-12 20:49:13

+0

请参阅GitHub页面上的README.md了解安装细节 – 2013-02-13 15:21:53