iOS Interview Notes (1)

Be well prepared before the interview, be sure to understand the technical points written in your resume thoroughly, and be able to express them completely

Below is a list of some of the questions worthy of being listed in today's interview.

1. How H5 interacts with native

      (1) js passes parameters to the native, the first way: through the proxy method of UIWebView - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest: (NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType; To monitor URL changes, If the H5 side needs to process an event natively or pass parameters, the content can be spliced ​​into the URL according to the format defined by both parties, and the native intercepts the jump according to the data in the URL, and performs the next operation. The second way: use native framework <JavaScriptCore/JavaScriptCore>


JSContext context = [webView valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"];
    //JS calls OC without parameters
    _context[@"jsMethod"] = ^() {
        
        //Use an array to receive multiple parameters passed in
        NSArray *params = [JSContext currentArguments];
        //then take the corresponding value
        NSString *str1 = params[0];
        NSString *str2 = params[1];
        
    };
Note that the "jsMethod" method here must be consistent with that in H5, in order to get parameters through this method

      (2) To pass parameters to js natively, usestringByEvaluatingJavaScriptFromString方法

[_webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"func('%@', '%@');", str2, str3]];
     (3) Another way is to use the third-party framework WebViewJavascriptBridge directly .


2. What are the differences between WKWebView and the original UIWebView

     (1) WKWebView has the following characteristics compared to UIWebView

  • The memory usage is 1/4~1/3 of uiwebview
  • Page loading speed improved
  • More detailed splitting of methods in UIWebViewDelegate
  • Page caching is not supported
     (2) WKWebView has also increased the use of WKWebView in the proxy method


3. What issues need to be paid attention to when adapting to iOS10

     (1) Privacy permission issue. When private data such as albums, cameras, contacts, etc. are accessed in the project, the corresponding key needs to be added to the info.plist file


     (2) Message push problem This article describes the iOS10 push in detail


Fourth, the optimization problem of UITableView

     (1) Handle the problem of cell reuse

     (2) Save the calculated cell height to avoid repeated calculations

      (3) Try to set the opaque of the cell and its subviews to YES

      (4) Use less or no clear coat

      (5) Avoid using layer to cut rounded corners

      (6) Reduce the number of self views on the contentview

      (7) Use addView as little as possible to dynamically add View to Cell, add it during initialization, display or hide it dynamically

      (8) Use drawing to draw complex interfaces asynchronously


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325524909&siteId=291194637