每次刷新Objective-C之后增加页面



我有一个 UIViewController,其中我有3个 UIWebView。我以编程为Webview添加了左侧的滑动。现在,我可以滑动,但只有3页,然后再次重复。我想增加我的当前页面并将其添加到我的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;
}

CurturnPage是一个整数,一开始就是0。我的问题是如何将CurrentPage添加到WebView3中,以便当我刷卡时会增加我的页面?

 - (void)swipeLeftAction:(id)ignored
 {
NSLog(@"Swipe Left");
UIWebView *temp = webView2 ;
webView2 = webView3;
webView3 = webView;
webView = temp;
[webView2 bringToFront];
currentPage++;
 }

预先感谢!

****编辑:**

此当前页面未连接到任何WebView,我如何在WebView中获得此增加?**

基于此帖子的信息(UigeSturerecognizer在UIWebView上起作用吗?。也许最好的方法是在网络浏览量中添加链接,当触摸时,请使用自己的方案来增加CurrentPage

-(BOOL) webView:(UIWebView *)inWeb shouldStartLoadWithRequest:(NSURLRequest *)inRequest navigationType:(UIWebViewNavigationType)inType {
  if ( [[[inRequest URL] absoluteString] hasPrefix:@"mySchemeIncrementPage:"] ) {
    currentPage++;
    NSLog(@"CURRENT PAGE COUNT: %i", currentPage);
    return NO;
  }
}

相关内容

最新更新