Thứ Sáu, 31 tháng 7, 2015

Swift : working with UITableView

1). Cell selection:
Link: http://stackoverflow.com/a/29821638

Overide willSelectRowAtIndexPath, return nil

2). Hidden seperator
setting at viewDidLoad()
tableView.separatorStyle = UITableViewCellSeparatorStyle.None

3).Height for custom cell
override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat
    {
        switch (cell) {
        case ("abc"): // cell's height
            return 180
        default:
            return UITableViewAutomaticDimension // return other cell's height
        }
    }

4). Execute after reloadData()
Link: http://stackoverflow.com/a/18812830

extension UITableView {
    func reloadData(completion: ()->()) {
        UIView.animateWithDuration(0, animations: { self.reloadData() })
            { _ in completion() }
    }
}

...somewhere later...

tableView.reloadData {
    println("done")
}

Objective-C:
[UIView animateWithDuration:0 animations:^{
    [myTableView reloadData];
} completion:^(BOOL finished) {
    //Do something after that...
}];

Continue ...
- Comments

0 nhận xét:

Đăng nhận xét