美文网首页iOS开发技巧
iOS 开发中的奇技淫巧

iOS 开发中的奇技淫巧

作者: 哎呀我Qu | 来源:发表于2016-11-13 17:56 被阅读48次
  • 在开发中,经常会遇到各种意想不到的问题。踩过了坑,自然就知道了躲坑和填坑的方法。这篇文章将自己解决问题的方法分享给大家(持续更新)

  1. 有时 pod install 或者 pod update 会卡在 Analyzing dependencies 好久,是因为这两个命令执行时会更新 CocoaPods 的 spec 仓库,替换为如下命令可跳过这一步
pod install --verbose --no-repo-update
pod update --verbose --no-repo-update
  1. 在 xib 中需要设置图片圆角时,不必拖线写代码
self.headView.layer.cornerRadius  = 30;
self.headView.layer.masksToBounds = YES;

只需在右侧进行如下设置即可实现圆角


设置圆角.png
  1. 当使用 git 向仓库中 push 代码时,经常会有 .DS_Store 文件冲突。这是存储文件位置信息的文件,创建 .gitignore 文件,如下编辑,即可忽略该文件
# Xcode
.DS_Store
*/build/*
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
profile
*.moved-aside
DerivedData
.idea/
*.hmap
  1. iOS 10 之后的权限获取,需在 Info.plist 中新增如下配置
<key>NSAppleMusicUsageDescription</key>
 <string>App需要您的同意,才能访问媒体资料库</string>

 <key>NSBluetoothPeripheralUsageDescription</key>
 <string>App需要您的同意,才能访问蓝牙</string>

 <key>NSCalendarsUsageDescription</key>
 <string>App需要您的同意,才能访问日历</string>

 <key>NSCameraUsageDescription</key>
 <string>App需要您的同意,才能访问相机</string>

 <key>NSHealthShareUsageDescription</key>
 <string>App需要您的同意,才能访问健康分享</string>

 <key>NSHealthUpdateUsageDescription</key>
 <string>App需要您的同意,才能访问健康更新 </string>

 <key>NSLocationAlwaysUsageDescription</key>
 <string>App需要您的同意,才能始终访问位置</string>

 <key>NSLocationUsageDescription</key>
 <string>App需要您的同意,才能访问位置</string>

 <key>NSLocationWhenInUseUsageDescription</key>
 <string>App需要您的同意,才能在使用期间访问位置</string>

 <key>NSMicrophoneUsageDescription</key>
 <string>App需要您的同意,才能访问麦克风</string>

 <key>NSMotionUsageDescription</key>
 <string>App需要您的同意,才能访问运动与健身</string>

 <key>NSPhotoLibraryUsageDescription</key>
 <string>App需要您的同意,才能访问相册</string>

 <key>NSRemindersUsageDescription</key>
 <string>App需要您的同意,才能访问提醒事项</string>
  1. Xcode 8 中 "xxx is missing from working copy" 警告解决方法
    做毕业设计,调整目录结构后发现出现好几个 "is missing from working copy" 的警告,这是以前没出现过的,强迫症不能忍啊有木有。解决方法如下:
    (1) 取消勾选 Enable Source Control
Xcode->Preferences->Source->Enable Source Control
Source Control.png

(2) 直接在终端操作
如果使用 git

git rm xxx

如果使用 svn

svn delete xxx

相关文章

网友评论

本文标题:iOS 开发中的奇技淫巧

本文链接:https://www.haomeiwen.com/subject/gfmouttx.html