ios晋级之路之奇技淫巧

一. UI相关


UITableView

1. UITableView自动布局的自动行高

描述:使用AutoLayout的UITableViewCell,不用计算heightForRow,由自动布局自动生成行高。

解决:设置estimatedRowHeight 和 rowHeight属性,删除heightForRow
eg:    mTableView.estimatedRowHeight = 150
       mTableView.rowHeight = UITableViewAutomaticDimension

2. UILabel 设置 NSAttributedString时lineBreak不显示

描述:文本内容超过UILabel的lines限制,依然不会显示"...",像直接内容丢失了一样。

解决:先设置attributedText属性,再设置lineBreakMode(顺序很重要)
eg:  mSkill.attributedText = aViewModel.attributeSkill
     mSkill.lineBreakMode = .byTruncatingTail

2. rightBarButtonItem 距离屏幕右边边距

解决办法:

let aSpace = UIBarButtonItem(barButtonSystemItem: .fixedSpace, target: nil, action: nil)
aSpace.width = -5 // (右移5)
self.navigationItem.rightBarButtonItems = [aSpace, item] // 注意顺序,  rightBarButtonItems是从右向左

二. 其它

1.Unable to access Photos Permission

描述: 使用Permission库时, 如果当前CocoaPod版本为1.2.1, 会导致编译不通过.
解决办法:

pod 'Permission/Microphone', :git => 'https://github.com/leoneparise/Permission', :branch => 'master'

你可能感兴趣的:(ios晋级之路之奇技淫巧)