如何encode:
let urlStrEncode = urlStr.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding)
或者
let urlStrEncode = urlStr.stringByAddingPercentEncodingWithAllowedCharacters( NSCharacterSet.URLQueryAllowedCharacterSet())
顺道再贴下如何decode:
let[......]
Category Archives: iOS
[转] edgesForExtendedLayout
如果使用了UINavigationViewController,在iOS7后,默认的子viewcontroller会跑到navvc的底下,遮挡一部分,解决方法是设置:
class BaseViewController: UIViewController {
override func viewDidLoad() {
// make vc top edge start from navigation bar's bottom
self.edges[......]
Objective C中的浅拷贝和深拷贝
其实和Java很类似的,浅拷贝要实现用NSCopying,深拷贝要实现NSMutableCopying,举个例子:
摘抄自:http://stackoverflow.com/questions/11329754/is-this-a-reasonable-pattern-for-implementing-nsmutablecopying
// BBMovie.h
@interface BBMovie : NSObject < NSCopying, NSMutableCopyin[......]
[转]AutoResizing的不合理布局
转载自:http://www.jianshu.com/p/b637d3d21606
不合理布局
UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin
view与其superView的左边距和右边距的比例维持不变,上下间距固定,宽高固定(下图的xib中预览效果与实际效果有差,实际效果是view的上边距不变)这种约束方式相当于上下间距固定,宽高固定,那么父控件高度缩放的时候就会产生冲突,所以这种[......]