Skip to content

Commit 1fc08a0

Browse files
committed
Added goback and goforward methods
1 parent 9aae62e commit 1fc08a0

3 files changed

Lines changed: 43 additions & 1 deletion

File tree

AQWebView.ios.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,27 @@ var {
55
} = React;
66

77
class WKWebView extends React.Component {
8+
9+
goBack() {
10+
this.refs.AQWebView.goBack();
11+
}
12+
13+
goForward() {
14+
this.refs.AQWebView.goForward();
15+
}
16+
17+
canGoForward() {
18+
this.refs.AQWebView.canGoForward();
19+
}
20+
21+
canGoBack() {
22+
this.refs.AQWebView.canGoBack();
23+
}
24+
825
render() {
9-
return <AQWebView {...this.props} />;
26+
return <AQWebView ref="AQWebView" {...this.props} />;
1027
}
28+
1129
}
1230

1331
WKWebView.propTypes = {

AQWebView/AQWebView.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,9 @@
88
@property (nonatomic, copy) NSArray<NSString*> *blockedPrefixes;
99

1010
- (void)reload;
11+
- (void)goBack;
12+
- (void)goForward;
13+
- (BOOL)canGoBack;
14+
- (BOOL)canGoForward;
1115

1216
@end

AQWebView/AQWebView.m

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,26 @@ - (void)reload
7272
[_webView loadRequest:[NSURLRequest requestWithURL:_webView.URL]];
7373
}
7474

75+
- (void)goBack
76+
{
77+
[_webView goBack];
78+
}
79+
80+
- (void)goForward
81+
{
82+
[_webView goForward];
83+
}
84+
85+
- (BOOL)canGoBack
86+
{
87+
return [_webView canGoBack];
88+
}
89+
90+
- (BOOL)canGoForward
91+
{
92+
return [_webView canGoForward];
93+
}
94+
7595
- (void)setSource:(NSDictionary *)source
7696
{
7797
if (![_source isEqualToDictionary:source]) {

0 commit comments

Comments
 (0)