随笔分类 -  iOS

摘要:项目开发的时候,会碰到测试服务器和正式服务器,或是大体功能一致,部分区别的时候。我们可以使用多Target来管理项目,免去复制代码的,然后在多个文件夹中查找代码切换项目的问题。 1.Targets duplicate 2.Rename target 3.设置图片 Assets.xcassets,Ap 阅读全文
posted @ 2017-04-05 09:14 Lawerence 阅读(333) 评论(0) 推荐(0)
摘要:最近项目中需要对图片(包括静态图和动图GIF)进行一些自定义的操作,比如添加文本,图片,或是其他页面元素。就此把所学分享出来。 Quartz2D Quartz2D是苹果公司提供的二维绘图引擎,可以实现绘图,绘制文字,绘制图片,截图,裁剪图片等功能。 静态图:即把当前View上的所有东西保存成一个新的 阅读全文
posted @ 2017-03-17 20:25 Lawerence 阅读(651) 评论(1) 推荐(1)
摘要:使用@synthesize编译器会确实的产生getter和setter方法,而@dynamic仅仅是告诉编译器这两个方法在程序运行的时候或者用其他方式动态绑定,以便让编译器通过编译,无需产生警告。其主要的作用就是用在NSManagerObject对象的属性声明上,由于此类对象的属性一般是从Core Data的属性中生成的,core data 框架会在程序运行的时候为此类属性生成getter和setter方法。假设有这么个场景,B类,C类分别继承A类,A类实现某个协议(@protocol),协议中某个属性( somePropety)我不想在A中实现,而在B类,C类中分别实现。如果A中不写任何代码 阅读全文
posted @ 2013-06-04 09:30 Lawerence 阅读(367) 评论(0) 推荐(0)
摘要:在UIWebView上加手势View Code 1 UITapGestureRecognizer* singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self2 action:@selector(handleSingleTap:)];3 [self.view addGestureRecognizer:singleTap];4 singleTap.dele... 阅读全文
posted @ 2013-03-11 15:27 Lawerence 阅读(264) 评论(0) 推荐(0)
摘要:FMDB 简单的使用GitHub链接地址:https://github.com/ccgus/fmdb需要引入的文件有:并导入libsqlite2.dylibView Code 1 1 // Library/Caches 2 2 NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES); 3 3 NSString *cachePath = [paths lastObject]; 4 4 NSLog(@"%@", cache... 阅读全文
posted @ 2012-10-30 14:52 Lawerence 阅读(256) 评论(0) 推荐(0)
摘要:reference: http://blog.mugunthkumar.com/products/ios-framework-introducing-mknetworkkit/网络请求,asi已经不在维护,新的http request。全面支持ARC,这样是一个主流,xcode 4.5 preview中已经不提供4.3的simulator。先标记研究,后续上内容。1.直接看code,相信能看懂View Code MKNetworkEngine *workEngine = [[MKNetworkEngine alloc] initWithHostName:@"thgame.phpfog 阅读全文
posted @ 2012-09-12 11:28 Lawerence 阅读(794) 评论(0) 推荐(0)
摘要:昨天搞了一天的GZip压缩,试了三种方式(libz库,ZipArchive,ASIHttpRequest),一开始都不成功。理论上三个应该都能用的,但我都不行。等我试到第三种方式的时候才知道,不是我的问题,而是后台的问题(Java端输出方式一会再说)。今天就总结一下,写写iOS与Java服务器获取压缩数据的方法吧。一、客户端-服务端数据压缩解压流程(ASIHttpRequest)客户端生成request,设置header允许使用压缩("Accept-Encoding","gzip"),即是告诉服务器,客户端支持压缩,但凡可以压缩的服务器,尽管来吧!服务器 阅读全文
posted @ 2012-08-20 09:43 Lawerence 阅读(1362) 评论(0) 推荐(0)
摘要:1.处理textView的return事件- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{ if (1 == range.length) { //空格 return YES; } if ([text isEqualToString:@"\n"]) { //return [textView resignFirstResponder]; return NO; } return NO;} 阅读全文
posted @ 2012-07-27 17:29 Lawerence 阅读(187) 评论(0) 推荐(0)
摘要:1.当进入页面有大量数据要实时处理的时候(如处理网络数据,解析数据等),把需要处理的部分放在viewDidAppear中,然后加上等待动画,这样用户体验会好些!同样,加载大量数据的时候,在init中执行。 2.重写Pplaceholder的draw方法就可以了- (void) drawPlaceho 阅读全文
posted @ 2012-07-27 17:27 Lawerence 阅读(164) 评论(0) 推荐(0)
摘要:Step 1: Create cert request file。(当你在apple web site "provisioning portal"里生成"Development Certificate" 和 "Push SSL Certificate"时就会用到它)1. Access "keychain access" by selecting "Application > Utilities > keychain access"2. select menu "keycha 阅读全文
posted @ 2012-07-18 16:42 Lawerence 阅读(2018) 评论(1) 推荐(0)
摘要:- (void)updateMemberPins{ [map addAnnotations:locationArray]; if ([locationArray count] > 0) { CLLocationCoordinate2D topLeftCoord; topLeftCoord.latitude = -90; topLeftCoord.longitude = 180; CLLocationCoordinate2D bottomRightCoord; bottomRightCoor... 阅读全文
posted @ 2012-06-18 18:12 Lawerence 阅读(201) 评论(0) 推荐(0)
摘要:useful commands for Mac / iOS:(this will be updated if i find new useful command)show the hidden files in Mac: defaults write com.apple.finder AppleShowAllFiles YESshow the Library file in Mac: chflags nohidden ~/library/重新指定:sudo xcode-select -switch /Applications/Xcode.app/调度技巧调度技巧一:程序在崩溃的时候,xcod. 阅读全文
posted @ 2012-06-14 13:56 Lawerence 阅读(234) 评论(0) 推荐(0)
摘要:调试webService的接口,采用的soap协议,一直遇到一个问题,ErroeCode:415 unsupported media type,对于整个问题纠结了好久,一开始服务器有问题,改好后,请求还是出错。今天在网上找到如下的一段文字(见参考连接1),在加上一牛人的推荐的soapUI的工具,通过裸发soap报文,找到了问题的所在。soap 1.1拚出的Http request中的是xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"而soap1.2,则是xmlns:soap="http://www.w3. 阅读全文
posted @ 2012-06-04 19:24 Lawerence 阅读(466) 评论(0) 推荐(0)
摘要:UIView *customView;UIWindow *window = [[[UIApplication sharedApplication] keyWindow] addSubview:customView];in the ViewController:shouldAutorotateToInterfaceOrientation switch (interfaceOrientation) { case UIInterfaceOrientationLandscapeLeft: customView.transform = CGAffineTransf... 阅读全文
posted @ 2012-06-04 19:22 Lawerence 阅读(469) 评论(0) 推荐(0)