I'm using the SwipeView library to create a series of swipeable webview (https://github.com/nicklockwood/SwipeView).
After swiping back and forth a few times, the webviews are displayed out of order, and sometimes duplicated (item in position 1 is a duplicate of item in position 3, etc.)
There was a similar problem on github (https://github.com/nicklockwood/SwipeView/issues/40) but I think I'm setting up the reused view correctly.
- (UIView *)swipeView:(SwipeView *)swipeView viewForItemAtIndex:(NSInteger)index reusingView:(UIView *)view
{
UIWebView *webView = (UIWebView *) view;
if (webView == nil) {
webView = [[UIWebView alloc] initWithFrame:swipeView.frame];
UIRefreshControl *rControl = [[UIRefreshControl alloc] init];
[rControl addTarget:self action:@selector(handleRefresh:) forControlEvents:UIControlEventValueChanged];
[webView.scrollView addSubview:rControl];
}
webView.delegate = self;
NSString *strURL = _urls[index];
NSURL *url = [NSURL URLWithString:strURL];
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url];
[webView loadRequest:urlRequest];
return webView;
}
from debugger: (notice how _itemViews is out of order)
_itemViews __NSDictionaryM * 4 key/value pairs 0x08e5ce20
[0] (null) (int)0 : (no summary)
[1] (null) (int)3 : (no summary)
[2] (null) (int)1 : (no summary)
[3] (null) (int)2 : (no summary)
_urls __NSArrayM * @"4 objects" 0x14d9ca00
[0] __NSCFConstantString * @"http://cmcewen.ngrok.com/links/new" 0x000eac50
[1] __NSCFConstantString * @"http://cmcewen.ngrok.com/users/sign_in" 0x000eac60
[2] __NSCFString * @"http://cmcewen.ngrok.com/links/178" 0x14e49630
[3] __NSCFString * @"http://cmcewen.ngrok.com/links/178/comments" 0x14e4d510