@@ -56,11 +56,6 @@ - (id)initWithFile:(NSString*)urlString specifier:(IASKSpecifier*)specifier {
5656}
5757
5858- (void )loadView {
59- // Initialize the webView
60- self.webView = [[WKWebView alloc ] init ];
61- self.webView .translatesAutoresizingMaskIntoConstraints = NO ; // Disable autoresizing mask for layout constraints
62- self.webView .navigationDelegate = self;
63-
6459 // Set up the main view
6560 self.view = [[UIView alloc ] init ];
6661
@@ -71,19 +66,6 @@ - (void)loadView {
7166 // Fallback on earlier versions:
7267 self.view .backgroundColor = [UIColor whiteColor ];
7368 }
74- [self .view addSubview: self .webView];
75-
76- // Create constraints to match the entire safe area layout:
77- UILayoutGuide *safeArea = self.view .layoutMarginsGuide ;
78- if (@available (iOS 11.0 , *)) {
79- safeArea = self.view .safeAreaLayoutGuide ;
80- }
81- [NSLayoutConstraint activateConstraints: @[
82- [self .webView.topAnchor constraintEqualToAnchor: safeArea.topAnchor],
83- [self .webView.bottomAnchor constraintEqualToAnchor: safeArea.bottomAnchor],
84- [self .webView.leadingAnchor constraintEqualToAnchor: safeArea.leadingAnchor],
85- [self .webView.trailingAnchor constraintEqualToAnchor: safeArea.trailingAnchor]
86- ]];
8769
8870 // Define default activity indicator:
8971 self.activityIndicatorView = [[UIActivityIndicatorView alloc ] initWithFrame: CGRectMake (0 , 0 , 40 , 20 )];
@@ -104,15 +86,7 @@ - (void)loadView {
10486 self.progressView .progress = 0.0 ;
10587 self.progressView .hidden = YES ; // Will be shown by observer when enabled
10688 self.progressView .translatesAutoresizingMaskIntoConstraints = NO ; // Disable autoresizing mask for layout constraints
107- [self .view addSubview: self .progressView];
108-
109- // Create constraints to set it to the top of the webView:
110- [NSLayoutConstraint activateConstraints: @[
111- [self .progressView.topAnchor constraintEqualToAnchor: self .webView.topAnchor],
112- [self .progressView.leadingAnchor constraintEqualToAnchor: self .webView.leadingAnchor],
113- [self .progressView.trailingAnchor constraintEqualToAnchor: self .webView.trailingAnchor]
114- ]];
115-
89+
11690 // Create UIBarButtonItems with SF Symbols:
11791 if (@available (iOS 13.0 , *)) {
11892 self.backButton = [[UIBarButtonItem alloc ] initWithImage: [UIImage systemImageNamed: @" chevron.backward" ]
@@ -164,6 +138,43 @@ - (void)loadView {
164138 self.navigationItem .rightBarButtonItem = [[UIBarButtonItem alloc ] initWithCustomView: self .activityIndicatorView];
165139 }
166140
141+ if (self.hideBottomBar ) {
142+ // Hide the tab bar when this view is pushed:
143+ self.hidesBottomBarWhenPushed = YES ;
144+ }
145+ }
146+
147+ - (void )viewDidLoad {
148+ [super viewDidLoad ];
149+
150+ // Initialize the webView
151+ self.webView = [[WKWebView alloc ] init ];
152+ self.webView .translatesAutoresizingMaskIntoConstraints = NO ; // Disable autoresizing mask for layout constraints
153+ self.webView .navigationDelegate = self;
154+ [self .view addSubview: self .webView];
155+
156+ // Create constraints to match the entire safe area layout:
157+ UILayoutGuide *safeArea = self.view .layoutMarginsGuide ;
158+ if (@available (iOS 11.0 , *)) {
159+ safeArea = self.view .safeAreaLayoutGuide ;
160+ }
161+ [NSLayoutConstraint activateConstraints: @[
162+ [self .webView.topAnchor constraintEqualToAnchor: safeArea.topAnchor],
163+ [self .webView.bottomAnchor constraintEqualToAnchor: safeArea.bottomAnchor],
164+ [self .webView.leadingAnchor constraintEqualToAnchor: safeArea.leadingAnchor],
165+ [self .webView.trailingAnchor constraintEqualToAnchor: safeArea.trailingAnchor]
166+ ]];
167+
168+ // Add UIProgressView:
169+ [self .view addSubview: self .progressView];
170+
171+ // Create constraints to set it to the top of the webView:
172+ [NSLayoutConstraint activateConstraints: @[
173+ [self .progressView.topAnchor constraintEqualToAnchor: self .webView.topAnchor],
174+ [self .progressView.leadingAnchor constraintEqualToAnchor: self .webView.leadingAnchor],
175+ [self .progressView.trailingAnchor constraintEqualToAnchor: self .webView.trailingAnchor]
176+ ]];
177+
167178 // Enable progress observer depending on `IASKWebViewShowProgress`:
168179 if (self.showProgress ) {
169180 // Observe the `estimatedProgress` property of WKWebView:
@@ -172,11 +183,6 @@ - (void)loadView {
172183 options: NSKeyValueObservingOptionNew
173184 context: nil ];
174185 }
175-
176- if (self.hideBottomBar ) {
177- // Hide the tab bar when this view is pushed:
178- self.hidesBottomBarWhenPushed = YES ;
179- }
180186}
181187
182188- (void )viewWillAppear : (BOOL )animated {
0 commit comments