我正试图让选项卡浏览器就像safari或chrome一样带有选项卡。当用户打开新的url时,webview将被添加到数组中。当用户点击按钮,然后打开LoadedWebview:将调用并删除原始的webview,并从数组中打开加载的webview。
但这并没有发生。工作情况如下:webview从superview中移除是有效的。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];
}
您可以使用其中一个:https://github.com/graetzer/SGTabshttps://github.com/xxhp/BrowserTabViewDemo
我认为这就是您想要实现的目标:https://github.com/fictorial/BHTabBar