Tips & Trivia in UIKit

Reading time ~1 minute

This blog will mainly cover some iOS development details during my build of Meme2.0 App.


First off, it’s the UICollectionView. UICollectionView is very similar to UITableView, the most important three methods are numberOfItemsInSection(), cellForItemAtIndexPath(), and didSelectItemAtIndexPath(). Rather than Row, as the tableView uses, CollectionView uses Item instead. But their responsiblites are basically the same.

Another important thing to note is that you have to defiine a custom cell for each collection view, more than one type if necessary. A new file is needed when defining a custom cell, and don’t forget to add outlets to the corresponding labels or images in storyboard.

UICollectionViewFlowLayout is used to organize the items in a collection view. There are three properties needs to be defined: minimumLineSpacing, minimumInteritemSpacing , and itemSize. Some useful documentation.


Often, view contollers are embedded in Navigation Controller, where all view controllers will have a nav bar at the top. If we want to add items (like buttons) to the nav bar, the one we need is Bar Button Item rather than Navigation Item.

In Navigation Controller, when a view controller is pushed on to the view stack, it will slide from right to left. In the nav bar at the top, there will be a back button, which, when pressed, will automatically pop off the current view controller.


When adding data to table view or collection view dynamically, remember to call tableView.reloadData() or collectionView.reloadData() in the viewWillAppear() function. So when coming back from another view controller after manipulating data, the table view or collection view will also get an update.


In table views, the style of seperator between cells can be set in storyboard. You can have none rather than the ugly grey line.

双拼输入法

今天了解到了双拼输入法。其原理并不复杂,就是将汉语拼音的声母和韵母拆分开来,例如:“双” -- shuang -- sh & uang。大部分字母(按键)本身就是声母,然后每个按键被分配一些韵母。这样一来,任何汉字都可以通过敲击两次按键被打出。对比全拼输入法,双拼输入法的效...… Continue reading