iOS笔记杂记

  • Google Mobile Ads SDK更新至7.2.1不能编译,添加依赖库QuartzCore.framework后正常编译
  • imageName会把image缓存到手机内存里,不适合大量图片浏览会越来越卡。imageWithContentFile是只显示图片而不加载到手机内存里。所以在出来大量图片浏览的时候要用imagewithcontentfile。
  • 有个testflightapp的第三方测试平台,把ipa的包放上去,生成一个地址,这样就可以根据地址来访问ipa的包了。
  • [self.view addSubView:xx.view] 等于[self.view insertSubView:xx.view atIndex:[self.view.subViews count]]
   addSubview是一层一层往上加,新加的只能放到最上层。
   insertSubView可以控制将view添加到指定的层。
 
  • 让用户评价APP,使用苹果APPStore的URL链接
  NSString *templateReviewURL = @"itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=APP_ID";

  NSString *templateReviewURLiOS7 = @"itms-apps://itunes.apple.com/app/idAPP_ID";

  NSString *templateReviewURLiOS8 = @"itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?id=APP_ID&onlyLatestVersion=true&pageNumber=0&sortOrdering=1&type=Purple+Software";
  • 已知两个NSDate, 求两者时间差
  NSDate *firstDate;
  NSDate *secondDate;   

  NSTimeInterval firstTime = [firstDate timeIntervalSince1970];
  NSTimeInterval secondTime = [secondDate timeIntervalSince1970];
  if((secondTime - firstTime) > 0) {
    //
  }
  • <Error>: ImageIO: CGImageReadCreateDataWithMappedFile 'open' failed '路径' error = 2 (No such file or directory)

  1.从本地沙盒读取图片,加载到UIimageViews上。

  2.删除沙盒里的图片。

  3.将UIImageView里的图片保存到本地沙盒时,出现错误:

  <Error>: ImageIO: CGImageReadCreateDataWithMappedFile 'open' failed '路径'
  error = 2 (No such file or directory)

  原因解析与解决方法:
  原因:保存时,图片已经不存在了,所以保存失败。
  解决方案:从路径读取图片后,先转换成NSData,再生成一张新的image,之后保存就OK。

  UIImage *tempImage = [[UIImage alloc] initWithContentsOfFile:path];  
  NSData *tempData = UIImageJPEGRepresentation(tempImage, 1.0);  
  UIImage *newImage = [UIImage imageWithData:tempData];
  • cell的间距是由cell的大小itemSize和section的缩进sectionInset共同决定的
  • imageview设置aspect fill属性后,图像可能会“撑破”图像视图
  • 设置titleEdgeInsets和imageEdgeInsets改变按钮上文字和图片的位置
原文地址:https://www.cnblogs.com/liuliuliu/p/4495273.html