- 博客(31)
- 收藏
- 关注
原创 去掉web显示页的广告
- (void)webViewDidFinishLoad:(UIWebView *)webView{ [webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.getElementsByClassName('adpic')[0].style.display = 'none'"];}
2016-06-07 14:58:16
413
原创 iOS开发常用代码片段整理
1.判断邮箱格式是否正确的代码//利用正则表达式验证-(BOOL)isValidateEmail:(NSString *)email{NSString *emailRegex = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";NSPredicate *emailTest = [NSPredicate predicateWithForma
2016-06-02 14:54:32
329
原创 数组排序
NSMutableArray *feedsBuffer; //初始化buffer以及填充数据 //……. //排序只需要两句话:已针对数组内对象的publishTime属性(NSDate)排序为例:NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"publishTime" ascending:N
2016-04-18 17:38:27
220
原创 TableView分割线左对齐
//分割线左对齐-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{ if ([cell respondsToSelector:@selector(setSeparatorInset:)])
2016-03-23 15:06:51
331
原创 iOS禁用返回手势
// 禁用返回手势,需要开启只需设置为yes即可。默认开启 if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) { self.navigationController.interactivePopGestureRecognizer.enabled = NO
2016-03-18 10:37:15
879
原创 根据图片url获取图片尺寸
// 根据图片url获取图片尺寸 +(CGSize)getImageSizeWithURL:(id)imageURL { NSURL* URL = nil; if([imageURL isKindOfClass:[NSURL class]]){ URL = imageURL; } if([imageURL isKindOfClass:[N
2016-02-17 13:26:10
1015
原创 iOS图片拉伸
http://onevcat.com/2011/12/uiimage/ http://blog.youkuaiyun.com/q199109106q/article/details/8615661 http://www.jianshu.com/p/c9cbbdaa9b02
2016-02-16 08:49:34
265
原创 NSDateFormatter 优化
NSDateFormatter对象本身初始化很慢,同样还有NSCalendar也是如此.然而在一些使用场景中不可避免要使用他们,比如Json数据解析中.使用这个对象同时避免其性能开销带来性能开销,一般比较好的方式是通过添加属性(推荐)或创建静态变量保持该对象只被初始化一次,而被多次复用.不得不值得一提的是设置一个NSDateFormatter属性速度差不多是和创建新的实例对象一样慢!static N
2016-01-27 13:42:55
312
原创 修改导航栏返回按钮
在+initialize方法中设置所有返回按钮文字的偏移量[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -100) forBarMetrics:UIBarMetricsDefault];
2016-01-27 11:46:08
315
原创 CFBundleShortVersionString与CFBundleVersion
CFBundleShortVersionString表示一个App的发行版本号(也就是用户一定可以看到的),它是一个String类型的值,适用于iOS和OS X平台。它的值的格式是由3个整数以(.)点号分隔的形式。第一个整数代表有新的功能或是重大的修改,第二个整数代表修改或实现一些不太重要的功能,第三个整数代表维护版本(类似于版本迭代)。CFBundleVersion 表示一个App的构建版本号(也
2015-12-16 17:32:15
1857
原创 颜色渐变
CAGradientLayer *colorLayer = [CAGradientLayer layer];colorLayer.frame = (CGRect){CGPointZero, CGSizeMake(200, 200)};colorLayer.position = self.view.center;[self.view.layer addSublayer:colorLayer];/
2015-12-07 14:20:34
254
原创 获取当前时间的年、月、日、时、分、秒
NSDate *now = [NSDate date];NSLog(@"now date is: %@", now);NSCalendar *calendar = [NSCalendar currentCalendar];NSUInteger unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NS
2015-12-01 09:43:18
391
原创 图片在沙盒中的存在形式
1.如果项目的Deployment Target <= 6.x (不支持图片压缩) 1> 所有图片直接暴露在沙盒的资源包(main Bundle), 不会压缩到Assets.car文件2.如果项目的Deployment Target >= 7.x (支持图片压缩) 1> 放在Images.xcassets里面的所有图片会压缩到Assets.car文件, 不会直接暴露在沙盒的资源包(main Bu
2015-11-17 17:40:50
283
原创 iOS应用跳到App Store
/跳转到应用页面NSString *str = [NSString stringWithFormat:@"http://itunes.apple.com/us/app/id%d",appid]; [[UIApplication sharedApplication]openURL:[NSURL urlWithString:str]];//跳转到评价页面NSString *str = [NSString
2015-10-28 13:54:25
242
原创 更新到10.11后 cocoapods 重装问题
更新到10.11后 cocoapods 需要重新安装,但是使用原来的淘宝源(http://ruby.taobao.org/)会报错ERROR: Could not find a valid gem ‘cocospods’ (>= 0), here is why: Unable to download data from http://ruby.taobao.org/ - bad resp
2015-10-28 13:49:56
302
原创 去掉UItableview headerview黏性(sticky)
(void)scrollViewDidScroll:(UIScrollView *)scrollView { CGFloat sectionHeaderHeight = 40; if (scrollView.contentOffset.y<=sectionHeaderHeight&&scrollView.contentOffset.y>=0) { scrollView.contentInset
2015-10-10 18:01:37
208
原创 浮点数等值比较
浮点数等值比较使用下式:includeincludefabs(a - b) < FLT_EPSILON三个EPSILON: FLT_EPSILON //双精度 DBL_EPSILON //单精度 LDBL_EPSILON
2015-10-10 09:42:42
773
原创 数组不能有nil的对象,字典不能插入nil的值
Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘* -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[2]’ * First th
2015-10-06 10:55:38
640
原创 画虚线边框
CAShapeLayer *border = [CAShapeLayer layer];border.strokeColor = SLColorLine.CGColor;border.fillColor = nil;border.path = [UIBezierPath bezierPathWithRect:self.bounds].CGPath; //border.path = [UIBezie
2015-10-04 22:55:23
437
原创 如何清除xcode里面的mobileprovision文件
清除所有的mobileprovision通过终端进行删除首先cd到目录cd ~/Library/MobileDevice/Provisioning\ Profiles/然后删除里面所有的mobileprovision文件rm *.mobileprovision恢复需要的账号里的mobileprovision这样再看xcode的时候,所有的mobileprovision,发现没有任何provision
2015-09-09 17:26:04
271
原创 详细的SDWebImage 实现过程
1.入口 setImageWithURL:placeholderImage:options: 会先把 placeholderImage 显 示,然后 SDWebImageManager 根据 URL 开始处理图片。2.进入 SDWebImageManager-downloadWithURL:delegate:options:userInfo:,交给 SDImageCache 从缓存查找图片是否已经
2015-09-09 17:18:44
268
原创 tableView(group)设置顶部空白区域
- (CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{ if (section == 0) return CGFLOAT_MIN; return tableView.sectionHeaderHeight;}返回0原因的UITableVi
2015-09-07 10:03:55
340
原创 VVDocumenter-Xcode 注释插件安装
查看Xcode的UUID 方式1 在终端执行 defaults read /Applications/Xcode.app/Contents/Info DVTPlugInCompatibilityUUID 拷贝选中的字符串。 方式2 在/Applications目录中找到Xcode.app,右键”显示包内容”,进入Contents文件夹,双击Info.plist打开,找到DVTPlugInC
2015-09-06 14:20:30
239
原创 设置子视图Alpha不同于父视图
FatherView.backgroundColor = [[UIColor lightGrayColor] colorWithAlphaComponent:0.5];
2015-09-02 11:21:16
219
原创 nil/Nil/NULL/NSNull
标志 值 含义NULL (void *)0 C指针的字面零值nil (id)0 Objective-C对象的字面零值Nil (Class)0 Objective-C类的字面零值NSNull [NSNull n
2015-09-02 09:11:38
197
原创 iOS开发之指定UIView的某几个角为圆角
如果需要将UIView的4个角全部都为圆角,做法相当简单,只需设置其Layer的cornerRadius属性即可(项目需要使用QuartzCore框架)。而若要指定某几个角(小于4)为圆角而别的不变时,这种方法就不好用了。 对于这种情况,Stackoverflow上提供了几种解决方案。其中最简单优雅的方案,就是使用UIBezierPath。下面给出一段示例代码。UIView *view2 = [[
2015-09-01 17:07:54
233
原创 UIImage加载图片方式一般有两种
A:imagedNamed初始化 B:imageWithContentsOfFile初始化二者不同之处在于,imageNamed默认加载图片成功后会内存中缓存图片,这个方法用一个指定的名字在系统缓存中查找并返回一个图片对象.如果缓存中没有找到相应的图片对象,则从指定地方加载图片然后缓存对象,并返回这个图片对象.而imageWithContentsOfFile则仅只加载图片,不缓存.
2015-09-01 17:02:41
217
原创 使用cocoaPods import导入时没有提示的解决办法
1.选择target(就是左边你的工程target)—— BuildSettings —— search Paths 下的 User Header Search Paths2.并且点击“+”号添加一项:并且输入:“$(PODS_ROOT)”(没有引号),选择:recursive(会在相应的目录递归搜索文件): 这样设置完成之后,再在工程中导入cocoaPods安装的第三方类库就有提示了。
2015-08-26 15:50:08
510
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人