Tags

iOS

There are a tons of very useful resources out there for Swift and I have barely begun to scratch the surface. But below are some the resources that I have found invaluable in my few months of Swift coding.

http://objc.io is a website with 24 online magazine issues dealing with different iOS concepts in detail. Inspite of most of the articles written in Objective C, most of the concepts explained are iOS related which are relevant irrespective of the language used ( Swift or Objective C)

In this second method there is no straightforward way to change the style of the UITableViewCell as it was in previous method.

So when I was faced with this issue, I figured, this seems to be a pretty simple thing, Swift should have provided me a way with changing the cell style. I searched far and wide in stackoverflow.com and the only option is to create a new custom cell derived from UITableViewCell and override the constructor to change style if you are following the second method of initialization

So below is the sample custom cell to create a uitableview cell with .SubTitle style

Custom cell to use if you want to go by method 2

Swift

1

2

3

4

5

6

7

8

9

classCustomTableViewCell: UITableViewCell{

overrideinit(style:UITableViewCellStyle,reuseIdentifier:String?){

super.init(style:.Subtitle,reuseIdentifier:reuseIdentifier)

}

required init(coder aDecoder:NSCoder){

fatalError("init(coder:) has not been implemented")

}

}

Hopefully this will save you some time in trying to figure out if a simpler way exists

I solved some autolayout issues without much priori knowledge. Though it took long, it peaked my interest in reading more about autolayout. Below are few links ( mostly google results) about autolayout that I am hoping to read more thoroughly and write some blog posts on

WKWebView is the more performant webview control introduced by Apple for iOS and OSX apps. You can read more about this in my previous post. But as the post mentions there are many features missing that are present in the UIWebView control. One such quirk is related to how WKWebView handles javascript actions that result in an alert, prompt (or) request to open a new url in a new window(tab). If we dont correctly handle, all of these clicks will result in no-op in WKWebView.

WKWebView does not open any <a> links that have target=”_blank”. ( For eg: From inside a WKWebview, if you click on the trailers in http://www.tomcruise.com website , nothing happens). In desktop browser, if target is “_blank”, a new tab is opened. In the in-app browser, we usually want the page to load on top of the current one. In order to achieve that in WKWebView, the following steps need to be followed.

Make your view controller that handles the webView callbacks to implement WKUIDelegate

In the view controller add the following code. This code verifies if the navigationAction’s target frame is nil(happens when target=”_blank”) and calls loadRequest on the navigationAction.request using current webview. The method ends with returning nil as we did not create a webView and used the existing one instead

WKWebView does not display the following Javascript prompts that are requested by web page.

Javascript prompt that shows a message that user can dismiss by a button pressWKWebView does not render any of the following prompts that are initiated by javascript code inside the WKWebView

Javascript prompt with OK and Cancel buttons, asking for user to make a choice of further action

Javascript prompt that asks for text input from user with an OK and Cancel buttons

To ensure all these three different javascript prompts show up, ensure that you have implemented the following three WKUIDelegate methods. The delegate methods give us access to the completion handler and which type of Javascript prompt to create. We need to create an iOS alert in the delegate method and render it modally for users to interact with.