|
@@ -275,9 +275,13 @@ static NSDictionary* customCertificatesForHost;
|
275
|
275
|
_webView.UIDelegate = self;
|
276
|
276
|
_webView.navigationDelegate = self;
|
277
|
277
|
#if !TARGET_OS_OSX
|
|
278
|
+ if (_pullToRefreshEnabled) {
|
|
279
|
+ [self addPullToRefreshControl];
|
|
280
|
+ }
|
278
|
281
|
_webView.scrollView.scrollEnabled = _scrollEnabled;
|
279
|
282
|
_webView.scrollView.pagingEnabled = _pagingEnabled;
|
280
|
|
- _webView.scrollView.bounces = _bounces;
|
|
283
|
+ //For UIRefreshControl to work correctly, the bounces should always be true
|
|
284
|
+ _webView.scrollView.bounces = _pullToRefreshEnabled || _bounces;
|
281
|
285
|
_webView.scrollView.showsHorizontalScrollIndicator = _showsHorizontalScrollIndicator;
|
282
|
286
|
_webView.scrollView.showsVerticalScrollIndicator = _showsVerticalScrollIndicator;
|
283
|
287
|
_webView.scrollView.directionalLockEnabled = _directionalLockEnabled;
|
|
@@ -308,7 +312,6 @@ static NSDictionary* customCertificatesForHost;
|
308
|
312
|
_webView.allowsBackForwardNavigationGestures = _allowsBackForwardNavigationGestures;
|
309
|
313
|
}
|
310
|
314
|
|
311
|
|
-
|
312
|
315
|
- (void)removeFromSuperview
|
313
|
316
|
{
|
314
|
317
|
if (_webView) {
|
|
@@ -1156,6 +1159,35 @@ static NSDictionary* customCertificatesForHost;
|
1156
|
1159
|
}
|
1157
|
1160
|
}
|
1158
|
1161
|
|
|
1162
|
+- (void)addPullToRefreshControl
|
|
1163
|
+{
|
|
1164
|
+ UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
|
|
1165
|
+ _refreshControl = refreshControl;
|
|
1166
|
+ [_webView.scrollView addSubview: refreshControl];
|
|
1167
|
+ [refreshControl addTarget:self action:@selector(pullToRefresh:) forControlEvents: UIControlEventValueChanged];
|
|
1168
|
+}
|
|
1169
|
+
|
|
1170
|
+- (void)pullToRefresh:(UIRefreshControl *)refreshControl
|
|
1171
|
+{
|
|
1172
|
+ [self reload];
|
|
1173
|
+ [refreshControl endRefreshing];
|
|
1174
|
+}
|
|
1175
|
+
|
|
1176
|
+#if !TARGET_OS_OSX
|
|
1177
|
+- (void)setPullToRefreshEnabled:(BOOL)pullToRefreshEnabled
|
|
1178
|
+{
|
|
1179
|
+ _pullToRefreshEnabled = pullToRefreshEnabled;
|
|
1180
|
+
|
|
1181
|
+ if (pullToRefreshEnabled) {
|
|
1182
|
+ [self addPullToRefreshControl];
|
|
1183
|
+ } else {
|
|
1184
|
+ [_refreshControl removeFromSuperview];
|
|
1185
|
+ }
|
|
1186
|
+
|
|
1187
|
+ [self setBounces:_bounces];
|
|
1188
|
+}
|
|
1189
|
+#endif // !TARGET_OS_OSX
|
|
1190
|
+
|
1159
|
1191
|
- (void)stopLoading
|
1160
|
1192
|
{
|
1161
|
1193
|
[_webView stopLoading];
|
|
@@ -1165,11 +1197,11 @@ static NSDictionary* customCertificatesForHost;
|
1165
|
1197
|
- (void)setBounces:(BOOL)bounces
|
1166
|
1198
|
{
|
1167
|
1199
|
_bounces = bounces;
|
1168
|
|
- _webView.scrollView.bounces = bounces;
|
|
1200
|
+ //For UIRefreshControl to work correctly, the bounces should always be true
|
|
1201
|
+ _webView.scrollView.bounces = _pullToRefreshEnabled || bounces;
|
1169
|
1202
|
}
|
1170
|
1203
|
#endif // !TARGET_OS_OSX
|
1171
|
1204
|
|
1172
|
|
-
|
1173
|
1205
|
- (void)setInjectedJavaScript:(NSString *)source {
|
1174
|
1206
|
_injectedJavaScript = source;
|
1175
|
1207
|
|