技术文章分类(180)

技术随笔(11)

文章分类 -  Swift

摘要:看这篇文章之前,建议读者先了解一下通知NSNotifation的通信原理不好描述,我先上图:就是点击“完成”可以隐藏键盘和自己,键盘出来时他们也跟着出来,对,就是这种效果,非常常用1,设置keyboardHeaderview和“完成”(这里的self.keyboardHeaderView设置成了se... 阅读全文
posted @ 2014-07-17 15:20 坤哥MartinLi 阅读(1466) 评论(0) 推荐(0) 编辑
摘要:注意:星期三打印4,星期天打印1,星期一打印2 var calendar:NSCalendar = NSCalendar.currentCalendar() var comps:NSDateComponents = calendar.components(NSCalend... 阅读全文
posted @ 2014-07-16 22:56 坤哥MartinLi 阅读(307) 评论(0) 推荐(0) 编辑
摘要:注意:self.datas是数据源就是必须先处理数据源,再进行cell的操作。 func switchButtonAction(isButtonOn:Bool){ self.tableview.beginUpdates() if isButtonOn==true{ ... 阅读全文
posted @ 2014-07-16 14:19 坤哥MartinLi 阅读(1479) 评论(0) 推荐(0) 编辑
摘要:1,注意设置UIWindow的frame self.window = UIWindow(frame:CGRectMake(0,0,DeviceFrame.width,DeviceFrame.height+StatusBarFrame.height)) self.window.... 阅读全文
posted @ 2014-07-16 10:20 坤哥MartinLi 阅读(191) 评论(0) 推荐(0) 编辑
摘要:1,这里定义代理协议,并且调用delegate方法import UIKitprotocol FaceDelegate:NSObjectProtocol{ func selectedFaceImgAction(text:String)}class DelegateTestViewControll... 阅读全文
posted @ 2014-07-11 19:34 坤哥MartinLi 阅读(2220) 评论(0) 推荐(0) 编辑
摘要:1,这是UICollectionView单独做Controller时的用法跟UItableview不同的地方,collectionview需要设置FlowLayout//// WeatherCollectionViewController.swift// SwiftStudy3//// Cre... 阅读全文
posted @ 2014-07-11 14:18 坤哥MartinLi 阅读(2046) 评论(0) 推荐(0) 编辑
摘要:我封装了一个UIView类,只要触发事件调用即可//浏览照片 func browsePhoto(){ let li_ImageViewer:Li_ImageViewer = Li_ImageViewer(frame:DeviceFrame) li_ImageView... 阅读全文
posted @ 2014-07-10 16:52 坤哥MartinLi 阅读(1572) 评论(0) 推荐(0) 编辑
摘要:1,实现UIImagePickerControllerDelegate, UINavigationControllerDelegate这两个代理2,这里是拍照的触发事件/* 拍照 */ func takePhoto(sender:AnyObject!){ ... 阅读全文
posted @ 2014-07-10 14:35 坤哥MartinLi 阅读(1360) 评论(0) 推荐(0) 编辑
摘要:首先必须导入MapKit.framework库,并import 这里是配合CLLocationManager(获取经纬度)使用,如果不知道CLLocationManager的用法,请参照我前面不远处的某篇博客有非常详细的记录了它的使用 func locationManager(manager:... 阅读全文
posted @ 2014-07-09 19:47 坤哥MartinLi 阅读(1156) 评论(0) 推荐(0) 编辑
摘要:1,导入库,具体方法参考官方文档http://developer.amap.com/api/ios-sdk/guide/project/其中特别注意:AMap.bundle按照要求,拖进来选择copy if needed2,修改Build Setting的4个地方的配置信息以上两步操作,我想obj... 阅读全文
posted @ 2014-07-09 09:42 坤哥MartinLi 阅读(1258) 评论(0) 推荐(0) 编辑
摘要:习惯用代码说话 //设置“定位”单击和双击的效果 func setLocationButtonClickEvent(){ var gr1:UITapGestureRecognizer = UITapGestureRecognizer(target: se... 阅读全文
posted @ 2014-07-08 21:46 坤哥MartinLi 阅读(408) 评论(0) 推荐(0) 编辑
摘要:UITableViewDataSource里的方法注意要删除两个东西1,数据要删除一行2,然后删除teblviewcell // Override to support conditional editing of the table view. override func tableV... 阅读全文
posted @ 2014-07-07 18:26 坤哥MartinLi 阅读(492) 评论(0) 推荐(0) 编辑
摘要:1,引入库2,设置arc模式兼容(因为很多库本身不是arc模式)在Build Phases/Compile Sources找到对应的.m文件,设置"-fno-objc-arc",这样就兼容了如果你是swift开发,那么也可以引入objc库,也是上面两个操作,然后3,在Bridging-Header.... 阅读全文
posted @ 2014-07-07 11:53 坤哥MartinLi 阅读(235) 评论(0) 推荐(0) 编辑
摘要:首先声明,真的不容易,swift刚出来,网上基本上都没有资料,自己一步一步的摸索做出来的。1,导入libsqlite3.dylib库,并且在你的swift objc Bridging-Header.h里import 这里相当于,swift引用了一个objc库文件,需要使用混编技术,如果有不会的参照我... 阅读全文
posted @ 2014-07-02 15:59 坤哥MartinLi 阅读(856) 评论(0) 推荐(0) 编辑
摘要:一,swift(SwiftTest.swift)调用objc(ObjcTest.h/m)1,在<Mixed-Bridging.h中添加:import "ObjcTest.h" (如果没有Bridging.h,则添加一个,并且在Building setting/Swift Compiler/Obj... 阅读全文
posted @ 2014-07-01 15:50 坤哥MartinLi 阅读(644) 评论(0) 推荐(0) 编辑
摘要:在Swift语言中用了willSet和didSet这两个特性来监视属性的除初始化之外的属性值变化无需说太多,看看下面的代码你就能很快明白的import Foundationclass People : NSObject{ //普通属性 var firstName:String = "" ... 阅读全文
posted @ 2014-06-24 11:04 坤哥MartinLi 阅读(306) 评论(0) 推荐(0) 编辑
摘要:Swift语言使用var定义变量,但和别的语言不同,Swift里不会自动给变量赋初始值,也就是说变量不会有默认值,所以要求使用变量之前必须要对其初始化。如果在使用变量之前不进行初始化就会报错:var stringValue : String //error: variable 'stringValu... 阅读全文
posted @ 2014-06-24 10:10 坤哥MartinLi 阅读(127) 评论(0) 推荐(0) 编辑
摘要:1,读取代码: var diaryList:String = NSBundle.mainBundle().pathForResource("DiaryList", ofType:"plist") var data:NSMutableDictionary = NSMutableD... 阅读全文
posted @ 2014-06-19 12:07 坤哥MartinLi 阅读(4042) 评论(0) 推荐(0) 编辑
摘要:步骤:1,import CoreLocation2,实现协议:CLLocationManagerDelegate3,初始化并配置CLLocationManager,实现协议的方法didUpdateLocationsvar locationManager:CLLocationManager = CLL... 阅读全文
posted @ 2014-06-19 10:42 坤哥MartinLi 阅读(2142) 评论(0) 推荐(0) 编辑
摘要://1、root控制器的创建 var rootCtrl =RootViewController() var root:UINavigationController =UINavigationController(rootViewController: rootCtrl) ... 阅读全文
posted @ 2014-06-19 08:48 坤哥MartinLi 阅读(280) 评论(0) 推荐(0) 编辑