Today's Menu  Portugal
journal and plan nutrition
Instance Methods | List of all members
U4WebViewController Class Reference

#import <U4WebViewController.h>

Inheritance diagram for U4WebViewController:
Inheritance graph
[legend]
Collaboration diagram for U4WebViewController:
Collaboration graph
[legend]

Instance Methods

(void) - viewDidLoad [implementation]
 
(void) - viewWillAppear: [implementation]
 
(void) - userContentController:didReceiveScriptMessage: [implementation]
 
(void) - becomeResponder: [implementation]
 
(BOOL) - jsReturnIndication: [implementation]
 
(void) - jsTitleReturn: [implementation]
 
(void) - jsIngredientsReturn: [implementation]
 
(void) - jsInstructionReturn: [implementation]
 
(void) - logCopy [implementation]
 
(void) - setControlbarColor: [implementation]
 
(void) - fireSnippetScreen [implementation]
 
(void) - webView:didFinishNavigation: [implementation]
 
(void) - webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler: [implementation]
 
(void) - webView:runJavaScriptConfirmPanelWithMessage:initiatedByFrame:completionHandler: [implementation]
 
(void) - webView:runJavaScriptTextInputPanelWithPrompt:defaultText:initiatedByFrame:completionHandler: [implementation]
 
(void) - webView:didCommitNavigation: [implementation]
 
(void) - webView:didStartProvisionalNavigation: [implementation]
 
(void) - webView:decidePolicyForNavigationResponse:decisionHandler: [implementation]
 
(void) - webView:decidePolicyForNavigationAction:decisionHandler: [implementation]
 
(void) - didReceiveMemoryWarning [implementation]
 

Detailed Description

Web View Controller

This bunch of modules provides for capturong information about recipes from the web, and maintaining pointers into the original page and the 'Print'

This is where the javascript evaluation of web pages is orchestrated

dot_inline_dotgraph_6.png

Action at the click of the web button on the camera snap View controller.

msc_inline_mscgraph_2
dot_inline_dotgraph_7.png

Definition at line 13 of file U4WebViewController.h.

Method Documentation

◆ becomeResponder:()

- (void) becomeResponder: (BOOL)  flag
implementation

Definition at line 147 of file U4WebViewController.m.

147  :(BOOL) flag
148 {
149  [webPanel becomeResponder:flag];
150  [self.view setNeedsLayout];
151  [self.view setNeedsDisplay];
152 
153  [self.view snapshotViewAfterScreenUpdates:YES];
154 }

◆ didReceiveMemoryWarning()

- (void) didReceiveMemoryWarning
implementation

Definition at line 414 of file U4WebViewController.m.

414  {
415  [super didReceiveMemoryWarning];
416  // Dispose of any resources that can be recreated.
417  NSLog(@"U4WebViewController.didReceiveMemoryWarning");
418 }

◆ fireSnippetScreen()

- (void) fireSnippetScreen
implementation

Definition at line 219 of file U4WebViewController.m.

220 {
221  NSLog(@"U4WebViewController.fireSnippetScreen: w/title: %@", mostRecentTitle);
222  W7WebSnippetViewController *parameterView =
223  [[W7WebSnippetViewController alloc] initWithNibName:nil bundle:nil];
224 
225  [parameterView setShowHtmlTitle:mostRecentTitle];
226 
227  NSAttributedString *titleSimple = [[NSAttributedString alloc] initWithData:[mostRecentTitle dataUsingEncoding:NSUTF8StringEncoding] options:@{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType, NSCharacterEncodingDocumentAttribute: [NSNumber numberWithInt:NSUTF8StringEncoding]} documentAttributes:nil error:nil];
228  [parameterView setShowTextTitle:[titleSimple string]];
229 
230 
231  [parameterView setShowHtmlIngredients:mostRecentIngredients];
232  [parameterView setShowHtmlInstruction:mostRecentInstruction];
233 
234  [self.navigationController pushViewController:parameterView animated:YES];
235 }
NSString * mostRecentTitle

◆ jsIngredientsReturn:()

- (void) jsIngredientsReturn: (NSString *)  string
implementation

Definition at line 178 of file U4WebViewController.m.

178  :(NSString *)string
179 {
180  if ([self jsReturnIndication:string]) {
181  mostRecentIngredients = [string copy];
182  }
183 }
NSString * mostRecentIngredients

◆ jsInstructionReturn:()

- (void) jsInstructionReturn: (NSString *)  string
implementation

Definition at line 184 of file U4WebViewController.m.

184  :(NSString *)string
185 {
186  if ([self jsReturnIndication:string]) {
187  mostRecentInstruction = [string copy];
188  }
189 }
NSString * mostRecentInstruction

◆ jsReturnIndication:()

- (BOOL) jsReturnIndication: (NSString *)  string
implementation

Definition at line 156 of file U4WebViewController.m.

156  :(NSString *)string
157 {
158  // NSLog(@"U4WebViewController.javaReturn: %@", string);
159  BOOL ret;
160  if (string) {
161  mostRecentJavascriptReturnStr = [string copy];
162  [webPanel.webControls setBackgroundColor:[UIColor greenColor]];
163  ret = YES;
164  } else {
165  mostRecentJavascriptReturnStr = @"Null return";
166  [webPanel.webControls setBackgroundColor:[UIColor orangeColor]];
167  ret = NO;
168  }
169  return ret;
170 }
NSString * mostRecentJavascriptReturnStr

◆ jsTitleReturn:()

- (void) jsTitleReturn: (NSString *)  string
implementation

Definition at line 171 of file U4WebViewController.m.

171  :(NSString *)string
172 {
173  NSLog(@"U4WebViewController.jsTitleReturn: string: %@", string);
174  if ([self jsReturnIndication:string]) {
175  mostRecentTitle = [string copy];
176  }
177 }
NSString * mostRecentTitle

◆ logCopy()

- (void) logCopy
implementation

Definition at line 191 of file U4WebViewController.m.

192 {
193  NSString *displayString = @"WEB COPY";
194  NSArray<NSString *> *pasteStrings = [[UIPasteboard generalPasteboard] pasteboardTypes];
195  // NSLog(@"U4WebViewController.logCopy: pasteStrings: %@", pasteStrings);
196  for (NSString *pasteStr in pasteStrings) {
197  // NSLog(@"U4WebViewController.logCopy: pasteStr: %@", pasteStr);
198  NSObject *valPasteType = [pasteboard valueForPasteboardType:pasteStr];
199  if (nil != valPasteType) {
200  NSLog(@"U4WebViewController.logCopy: has paste type: %@", pasteStr);
201 
202  NSString *addPasteType = [NSString stringWithFormat: @"%@ - %@", @"\n", pasteStr];
203  displayString = [displayString stringByAppendingString:addPasteType];
204 
205  if ([@"public.utf8-plain-text" isEqualToString:pasteStr]) {
206  NSObject *obj5 = [pasteboard valueForPasteboardType:pasteStr];
207  NSString *addInfo = [NSString stringWithFormat: @"%@", obj5];
208  displayString = [displayString stringByAppendingString:addInfo];
209  }
210  }
211  }
212  NSLog(@"U4WebViewController.logCopy: displayString: %@", displayString);
213 }

◆ setControlbarColor:()

- (void) setControlbarColor: (UIColor *)  color
implementation

Definition at line 214 of file U4WebViewController.m.

214  :(UIColor *)color
215 {
216  [webPanel.webControls setBackgroundColor:color];
217 }

◆ userContentController:didReceiveScriptMessage:()

- (void) userContentController: (WKUserContentController*)  userContentController
didReceiveScriptMessage: (WKScriptMessage*)  message 
implementation

Definition at line 136 of file U4WebViewController.m.

136  :(WKUserContentController*)userContentController
137  didReceiveScriptMessage:(WKScriptMessage*)message
138 {
139  // A new selected text has been received
140  NSLog(@"U4WebViewControler.userContentController-didReceiveScriptMessage");
141  if ([message.body isKindOfClass:[NSString class]])
142  {
143  NSLog(@"U4WebViewControler.userContentController: string");
144  }
145 }

◆ viewDidLoad()

- (void) viewDidLoad
implementation

Definition at line 103 of file U4WebViewController.m.

103  {
104  [super viewDidLoad];
105 
106  CGRect totalFrame = self.view.frame;
107  CGRect topNaviFrame = [[[self navigationController] navigationBar] frame];
108  float availableWindowTop = topNaviFrame.origin.y + topNaviFrame.size.height;
109 
110 
111  CGRect webViewFrame = CGRectMake(8,
112  availableWindowTop + 4,
113  totalFrame.size.width - 16,
114  totalFrame.size.height - availableWindowTop - 8);
115 
116 // WKWebViewConfiguration *config = [[WKWebViewConfiguration alloc] init];
117 // config.showConsole = YES;
118 
119  webPanel = [[Y3WebView alloc] initWithFrame:webViewFrame andDelegate:self];
120 
121 
122  [self.view addSubview:webPanel];
123 
124  NSURL *nsurl=[NSURL URLWithString:@"http://google.com"];
125  NSURLRequest *nsrequest=[NSURLRequest requestWithURL:nsurl];
126  [webPanel.webView loadRequest:nsrequest];
127 
128  mostRecentJavascriptReturnStr = [[NSString alloc] init];
129 }
NSString * mostRecentJavascriptReturnStr

◆ viewWillAppear:()

- (void) viewWillAppear: (BOOL)  animated
implementation

Definition at line 131 of file U4WebViewController.m.

131  :(BOOL)animated
132 {
133  [webPanel.webView setBackgroundColor:[UIColor grayColor]];
134  [webPanel setBackgroundColor:[UIColor colorWithHue:0.22 saturation:1.0 brightness:0.6 alpha:1.0]];
135 }

◆ webView:decidePolicyForNavigationAction:decisionHandler:()

- (void) webView: (WKWebView *)  webView
decidePolicyForNavigationAction: (WKNavigationAction *)  navigationAction
decisionHandler: (void(^)(WKNavigationActionPolicy))  decisionHandler 
implementation

Definition at line 302 of file U4WebViewController.m.

302  :(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler {
303 
304  NSURLRequest *request = navigationAction.request;
305  fileURL = request.URL;
306 
307 // HCDownloadViewController *dlvc = [[HCDownloadViewController alloc] init];
308 // UINavigationController *vc = [[UINavigationController alloc] initWithRootViewController:dlvc];
309 // vc.transitioningDelegate = self;
310 // dlvc.delegate = self;
311 
312  // NSLog(@"U4WebViewController.decidePolicyForNavigationAction: ~~~~~~~~~~~~~~~~~~~~~~");
313  // [self logNavigationAction:navigationAction];
314  if (navigationAction.navigationType == WKNavigationTypeLinkActivated) {
315 
316  //Internal file links
317  // NSString *internalFileExtension = fileURL.absoluteString.pathExtension;
318 // if ([fileExtensions containsObject:[internalFileExtension lowercaseString]]) {
319 //
320 // //Fire download
321 // // TODO: DLVC [dlvc downloadURL:fileURL userInfo:nil];
322 //
323 //
324 // [self presentViewController:vc animated:YES completion:nil];
325 // [vc release];
326 //
327 // NSLog(@"internalURL is %@", fileURL);
328 // if (decisionHandler) {
329 // decisionHandler(WKNavigationActionPolicyCancel);
330 // }
331 // return;
332 // }
333 //
334 // //External file extensions
335 // NSString *externalFileExtension = fileURL.pathExtension;
336 // if ([fileExtensions containsObject:[externalFileExtension lowercaseString]]) {
337 //
338 // //Fire download
339 // [dlvc downloadURL:fileURL userInfo:nil];
340 // [self presentViewController:vc animated:YES completion:nil];
341 // [vc release];
342 //
343 // NSLog(@"externalURL is %@", fileURL);
344 // if (decisionHandler) {
345 // decisionHandler(WKNavigationActionPolicyCancel);
346 // }
347 // return;
348 // }
349  }
350 
351  if (decisionHandler) {
352  decisionHandler(WKNavigationActionPolicyAllow);
353  }
354 }
WKWebView * webView
NSURL * fileURL

◆ webView:decidePolicyForNavigationResponse:decisionHandler:()

- (void) webView: (WKWebView *)  webView
decidePolicyForNavigationResponse: (WKNavigationResponse *)  navigationResponse
decisionHandler: (void(^)(WKNavigationResponsePolicy))  decisionHandler 
implementation

Definition at line 289 of file U4WebViewController.m.

289  :(WKWebView *)webView decidePolicyForNavigationResponse:(WKNavigationResponse *)navigationResponse decisionHandler:(void (^)(WKNavigationResponsePolicy))decisionHandler{
290  NSHTTPURLResponse *response = (NSHTTPURLResponse *)navigationResponse.response;
291  NSArray *cookies =[NSHTTPCookie cookiesWithResponseHeaderFields:[response allHeaderFields] forURL:response.URL];
292  for (NSHTTPCookie *cookie in cookies) {
293  [[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookie:cookie];
294  }
295 
296  decisionHandler(WKNavigationResponsePolicyAllow);
297  //NSLog(@"decidePolicyForNavigationResponse");
298 }
WKWebView * webView

◆ webView:didCommitNavigation:()

- (void) webView: (WKWebView *)  webView
didCommitNavigation: (WKNavigation *)  navigation 
implementation

Definition at line 277 of file U4WebViewController.m.

277  :(WKWebView *)webView
278 didCommitNavigation:(WKNavigation *)navigation
279 {
280  // NSLog(@"U4WebViewController.didCommitNavigation: active URL: %@", webView.URL.description);
281 }
WKWebView * webView

◆ webView:didFinishNavigation:()

- (void) webView: (WKWebView *)  webView2
didFinishNavigation: (WKNavigation *)  navigation 
implementation

Definition at line 238 of file U4WebViewController.m.

238  :(WKWebView *)webView2 didFinishNavigation:(WKNavigation *)navigation
239 {
240  [webPanel updateWebControls];
241  [webPanel.webControls setBackgroundColor:[UIColor blueColor]];
242  [webPanel scanPageForTitle];
243  [webPanel scanPageForIngredients];
244  [webPanel scanPageForInstruction];
245  NSLog(@"WebViewController.didFinishNavigation");
246 }

◆ webView:didStartProvisionalNavigation:()

- (void) webView: (WKWebView *)  webView
didStartProvisionalNavigation: (null_unspecified WKNavigation *)  navigation 
implementation

Definition at line 283 of file U4WebViewController.m.

283  :(WKWebView *)webView didStartProvisionalNavigation:(null_unspecified WKNavigation *)navigation
284 {
285  NSLog(@"U4WebViewController.didStartProvisionalNavigation: active URL: %@", webView.URL.description);
286  [webPanel.webControls setBackgroundColor:[UIColor whiteColor]];
287 }
WKWebView * webView

◆ webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:()

- (void) webView: (WKWebView *)  webView
runJavaScriptAlertPanelWithMessage: (NSString *)  message
initiatedByFrame: (WKFrameInfo *)  frame
completionHandler: (void(^)(void))  completionHandler 
implementation

Definition at line 248 of file U4WebViewController.m.

248  :(WKWebView *)webView
249 runJavaScriptAlertPanelWithMessage:(NSString *)message
250 initiatedByFrame:(WKFrameInfo *)frame
251 completionHandler:(void (^)(void))completionHandler
252 {
253  NSLog(@"U4WebViewController:runJavaScriptAlertPanelWithMessage");
254 }
WKWebView * webView

◆ webView:runJavaScriptConfirmPanelWithMessage:initiatedByFrame:completionHandler:()

- (void) webView: (WKWebView *)  webView
runJavaScriptConfirmPanelWithMessage: (NSString *)  message
initiatedByFrame: (WKFrameInfo *)  frame
completionHandler: (void(^)(BOOL result))  completionHandler 
implementation

Definition at line 256 of file U4WebViewController.m.

256  :(WKWebView *)webView
257 runJavaScriptConfirmPanelWithMessage:(NSString *)message
258 initiatedByFrame:(WKFrameInfo *)frame
259 completionHandler:(void (^)(BOOL result))completionHandler
260 {
261  NSLog(@"U4WebViewController:runJavaScriptConfirmPanelWithMessage");
262 }
WKWebView * webView

◆ webView:runJavaScriptTextInputPanelWithPrompt:defaultText:initiatedByFrame:completionHandler:()

- (void) webView: (WKWebView *)  webView
runJavaScriptTextInputPanelWithPrompt: (NSString *)  prompt
defaultText: (NSString *)  defaultText
initiatedByFrame: (WKFrameInfo *)  frame
completionHandler: (void(^)(NSString *result))  completionHandler 
implementation

Definition at line 265 of file U4WebViewController.m.

265  :(WKWebView *)webView
266 runJavaScriptTextInputPanelWithPrompt:(NSString *)prompt
267  defaultText:(NSString *)defaultText
268 initiatedByFrame:(WKFrameInfo *)frame
269 completionHandler:(void (^)(NSString *result))completionHandler
270 {
271  NSLog(@"U4WebViewController:runJavaScriptTextInputPanelWithPrompt");
272 }
WKWebView * webView

The documentation for this class was generated from the following files: