我有一个UIViewController
,里面有 3 个UIWebView
。我以编程方式向我的 webViews 添加了向左滑动。现在我可以滑动,但只有 3 页,然后再次重复。我想增加我的 currentPage 并将其添加到我的 webView3,但我不知道该怎么做。
你能给我一些提示吗?这部分我真的有问题!
这是我的代码:
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(@"test view");
NSURL *url = [NSURL fileURLWithPath:[ [ NSBundle mainBundle ] pathForResource: @"Name/Name1" ofType:@"html" ]];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[webView2 loadRequest:request];
[webView2 bringToFront];
NSURL *url = [NSURL fileURLWithPath:[ [ NSBundle mainBundle ] pathForResource:
@"Name/Name2" ofType:@"html" ]];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[webView3 loadRequest:request];
UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc]
initWithTarget:self action:@selector(swipeLeftAction:)];
swipeLeft.direction = UISwipeGestureRecognizerDirectionLeft;
swipeLeft.delegate = self;
[self.view addGestureRecognizer:swipeLeft];
}
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer
shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer
*)otherGestureRecognizer
{
return YES;
}
currentPage 是一个整数,一开始它是 0。我的问题是我应该如何将我的 currentPage 添加到 webView3 以便当我刷它时增加我的页面?
- (void)swipeLeftAction:(id)ignored
{
NSLog(@"Swipe Left");
UIWebView *temp = webView2 ;
webView2 = webView3;
webView3 = webView;
webView = temp;
[webView2 bringToFront];
currentPage++;
}
提前致谢!
****编辑:**
此当前页面未连接到任何 webView,如何在我的 webView 中获得这种增加?**