Commit 86372c21 cgx

新开的webview页面加载h5需要隐藏导航栏

1 个父辈 839f910b
...@@ -17,6 +17,11 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -17,6 +17,11 @@ NS_ASSUME_NONNULL_BEGIN
/// @param link 传入h5链接 /// @param link 传入h5链接
- (instancetype)initWithTitle:(NSString *)title link:(NSString *)link; - (instancetype)initWithTitle:(NSString *)title link:(NSString *)link;
/// 初始化方法
/// @param link 传入h5链接
/// @param isShowNavi 是否显示导航栏
- (instancetype)initWithLink:(NSString *)link isShowNavi:(BOOL)isShowNavi;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
@interface DsWebController () <WKNavigationDelegate> @interface DsWebController () <WKNavigationDelegate>
@property (nonatomic, copy) NSString *naviTitle; @property (nonatomic, copy) NSString *naviTitle;
@property (nonatomic, strong) NSURL *linkUrl; @property (nonatomic, strong) NSURL *linkUrl;
@property (nonatomic, assign) BOOL isShowNavi;
@property (nonatomic, strong) WKWebView *webView; @property (nonatomic, strong) WKWebView *webView;
@property (nonatomic, strong) NSMutableURLRequest *request; @property (nonatomic, strong) NSMutableURLRequest *request;
@property (nonatomic, strong) UIProgressView *progressView; @property (nonatomic, strong) UIProgressView *progressView;
...@@ -23,11 +24,20 @@ ...@@ -23,11 +24,20 @@
- (instancetype)initWithTitle:(NSString *)title link:(NSString *)link { - (instancetype)initWithTitle:(NSString *)title link:(NSString *)link {
if (self = [super init]) { if (self = [super init]) {
self.naviTitle = title; self.naviTitle = title;
self.isShowNavi = YES;
self.linkUrl = [NSURL URLWithString:link]; self.linkUrl = [NSURL URLWithString:link];
} }
return self; return self;
} }
- (instancetype)initWithLink:(NSString *)link isShowNavi:(BOOL)isShowNavi {
if (self = [super init]) {
self.linkUrl = [NSURL URLWithString:link];
self.isShowNavi = isShowNavi;
}
return self;
}
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
...@@ -54,6 +64,11 @@ ...@@ -54,6 +64,11 @@
return NO; return NO;
} }
#pragma mark - 隐藏导航栏
- (BOOL)isShowNavigationBar {
return !self.isShowNavi;
}
#pragma mark - WKWebView的监听方法 #pragma mark - WKWebView的监听方法
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context { - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSKeyValueChangeKey,id> *)change context:(void *)context {
if ([keyPath isEqualToString:@"estimatedProgress"]) { if ([keyPath isEqualToString:@"estimatedProgress"]) {
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!