mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-29 04:35:36 +08:00
Fix WebView example on iOS
Summary: Fixed broken scaling logic in Webview example for iOS. Pages must be reloaded after toggling `scalesPageToFit`, but that wasn't happening. Reviewed By: javache Differential Revision: D2982371 fb-gh-sync-id: 8442609179bfe9ade10d1d0bac1807e4a8855d00 shipit-source-id: 8442609179bfe9ade10d1d0bac1807e4a8855d00
This commit is contained in:
committed by
Facebook Github Bot 7
parent
f7df3bb78a
commit
7032a640e7
@@ -35,6 +35,7 @@ shouldStartLoadForRequest:(NSMutableDictionary<NSString *, id> *)request
|
||||
@property (nonatomic, assign) UIEdgeInsets contentInset;
|
||||
@property (nonatomic, assign) BOOL automaticallyAdjustContentInsets;
|
||||
@property (nonatomic, copy) NSString *injectedJavaScript;
|
||||
@property (nonatomic, assign) BOOL scalesPageToFit;
|
||||
|
||||
- (void)goForward;
|
||||
- (void)goBack;
|
||||
|
||||
@@ -118,6 +118,19 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder)
|
||||
updateOffset:NO];
|
||||
}
|
||||
|
||||
- (void)setScalesPageToFit:(BOOL)scalesPageToFit
|
||||
{
|
||||
if (_webView.scalesPageToFit != scalesPageToFit) {
|
||||
_webView.scalesPageToFit = scalesPageToFit;
|
||||
[_webView reload];
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)scalesPageToFit
|
||||
{
|
||||
return _webView.scalesPageToFit;
|
||||
}
|
||||
|
||||
- (void)setBackgroundColor:(UIColor *)backgroundColor
|
||||
{
|
||||
CGFloat alpha = CGColorGetAlpha(backgroundColor.CGColor);
|
||||
|
||||
@@ -36,8 +36,8 @@ RCT_EXPORT_MODULE()
|
||||
RCT_EXPORT_VIEW_PROPERTY(source, NSDictionary)
|
||||
RCT_REMAP_VIEW_PROPERTY(bounces, _webView.scrollView.bounces, BOOL)
|
||||
RCT_REMAP_VIEW_PROPERTY(scrollEnabled, _webView.scrollView.scrollEnabled, BOOL)
|
||||
RCT_REMAP_VIEW_PROPERTY(scalesPageToFit, _webView.scalesPageToFit, BOOL)
|
||||
RCT_REMAP_VIEW_PROPERTY(decelerationRate, _webView.scrollView.decelerationRate, CGFloat)
|
||||
RCT_EXPORT_VIEW_PROPERTY(scalesPageToFit, BOOL)
|
||||
RCT_EXPORT_VIEW_PROPERTY(injectedJavaScript, NSString)
|
||||
RCT_EXPORT_VIEW_PROPERTY(contentInset, UIEdgeInsets)
|
||||
RCT_EXPORT_VIEW_PROPERTY(automaticallyAdjustContentInsets, BOOL)
|
||||
|
||||
Reference in New Issue
Block a user