swift学习

Swift学习

1.deinit

2.objcBool:

包括:true和false

3.属性放在class外面

4.方法都要加()

5.XX as XX强制类型转换

6.跳转

let mainStoryboard = UIStoryboard(name: "你的storyboard名字",bundle: NSBundle.mainBundle())

let vc : UIViewController = mainStoryboard.instantiateViewControllerWithIdentifier("你的viewcontroller的storyboard ID")as UIViewController

self.presentViewController(vc,animated: true,completion: nil)

7.返回dismiss

8.button添加点击事件

按钮触摸点击事件响应

//不传递触摸对象(即点击的按钮)

button.addTarget(self,action:Selector("tapped"),forControlEvents:UIControlEvents.TouchUpInside)

functapped(){

println("tapped")

}

//传递触摸对象(即点击的按钮),需要在定义action参数时,方法名称后面带上冒号

button.addTarget(self,action:Selector("tapped:"),forControlEvents:UIControlEvents.TouchUpInside)

functapped(button:UIButton){

println(button.titleForState(.Normal))

}

9.属性的值与枚举比较,枚举需要类型

if(liveSession.state == LFLiveState.pending || liveSession.state == LFLiveState.start){

10.class在swift中不能使用,用swift代替

11.Xib的使用

collectionView.register(UINib(nibName: "CollectionHeaderView",bundle: nil),forSupplementaryViewOfKind: UICollectionElementKindSectionHeader,withReuseIdentifier: kHeaderViewID)

12.Swift中的willSetdidSet

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容