简体   繁体   English

ios7中UItableview中的UIwebview滚动问题

[英]UIwebview in UItableview scrolling issue in ios7

I am applying pull to refresh code in tableview. 我正在应用拉动以刷新tableview中的代码。 I have custom cell with UIwebview in it. 我有带有UIwebview的自定义单元格。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"CustomCell";
CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];

if(cell==nil){
    NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil];
    cell = [nib objectAtIndex:0];
    NSLog(@"%@",cell.subviews);
}
// Configure the cell...

NSURL *url = [NSURL URLWithString:@"http://www.google.com.au"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];

[cell.webView loadRequest:request];
return cell;

} }

in view didLoad 鉴于didLoad

- (void)viewDidLoad
{
[super viewDidLoad];
self.refreshControl = [[UIRefreshControl alloc] init];
[self.refreshControl addTarget:self action:@selector(refresh:) forControlEvents:UIControlEventValueChanged];
[self.tableView addSubview:self.refreshControl];

} }

- (void)refresh:(id)sender
{
// do somthing
NSLog (@"Refresh");
[self performSelector:@selector(stopRefresh) withObject:nil afterDelay:2.5];


}

- (void)stopRefresh {
    NSLog (@"Stop Refresh");

    [self.refreshControl endRefreshing];
}

It is behaving properly in iOS 6 and I am able to pull to refresh, but in iOS 7, only web view is scrolling not tableview. 它在iOS 6中表现正常,我可以刷新一下,但是在iOS 7中,只有Web视图在滚动而不是TableView。

Please help me out. 请帮帮我。

Try this 尝试这个

   - (void)refresh:(id)sender
    {
    NSLog (@"Refresh");
    [self performSelectorInBackground:@selector(stopRefresh) withObject:Nil];

    }

Hope this helps 希望这可以帮助

In iOS7 and above, The event is not getting passed from UIWebView scroll end to UITableView bounce due to the hierarchy changes and the framework changes. 在iOS7及更高版本中,由于层次结构更改和框架更改,事件未从UIWebView滚动端传递到UITableView反弹。

Programatically detecting if the scrollview is from UITableView or UIWebView if the scrollview is appWebView 以编程方式检测滚动视图是来自UITableView还是UIWebView(如果滚动视图是appWebView)

if([[scrollView superview] isEqual:appWebView]){
    if (scrollView.contentOffset.y<0) {
        CGPoint currentContentOffset = CGPointMake(0, scrollView.contentOffset.y);
        [appTableView setContentOffset:currentContentOffset animated:NO];
    }

}

try playing with this part according to your requirement in scrollView delegates. 根据您对scrollView委托的要求,尝试使用此部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM