15/10-16/6开发笔记
Posted 回读(IOS开发)
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了15/10-16/6开发笔记相关的知识,希望对你有一定的参考价值。
添加同一个控件多次到父控件,最终只会添加一个该控件
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TableView中设置backgroundView,设置ImageView出不来?
因为target为7,设置图片只有8才可以
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1.url编码
ios中http请求遇到汉字的时候,需要转化成UTF-8,用到的方法是:
NSString * encodingString = [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
2.url解码
请求后,返回的数据,如何显示的是这样的格式:%3A%2F%2F,此时需要我们进行UTF-8解码,用到的方法是:
NSString *str = [model.album_name stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
dataSourceArray和reloadData都要在主线程中完成
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*** Assertion failure in -[UITableView _dequeueReusableViewOfType:withIdentifier:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3512.30.14/UITableView.m:6532
解决:因为使用的tableViewCell的xib绑定了identifier,如果注册时候不跟xib保持一致就会报错,或者是代码哪里写错了,仔细检查代码。
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
后面带有UI_APPEARANE_SELECTOR的方法,都可以通过appearance统一设置
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
IQKeyboardManager
键盘在切换textfield的时候出现顺序有误,跟添加textfield控件顺序有关,调整顺序即可解决
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
获取子View所在控制器
- (UIViewController *)viewController
{
for (UIView* next = [self superview]; next; next = next.superview) {
UIResponder *nextResponder = [next nextResponder];
if ([nextResponder isKindOfClass:[UIViewController class]]) {
return (UIViewController *)nextResponder;
}
}
return nil;
}
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
This file is set to build for a version older than the project deployment target. Functionality may be limited.
解决方法:
选中xib 的文件,在 Builds for 中修改 Project Deployment Target
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
library not found for . . .
解决:.a文件未上传到服务器
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
libc++abi.dylib: terminate_handler unexpectedly threw an exception
2016.01.23
遇到了这个情况,发现是因为我从xib里拖出来的属性,被我改了名字导致
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
App installation failed
This application‘s application-identifier entitlement does not match that of the installed application. These values must match for an upgrade to be allowed.
解决:
iPhone上已经装了包标识符一样的 App,删掉再运行。
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
开发注意:
如果你建了一个类,比如:NCQRCodeViewController
那么你就不能在创建NCQRCodeView(包含xib)这样的类,否则会崩溃,原因是因为NCQRCodeViewController会先去找NCQRCodeView.xib,纳尼!就错在这儿了。
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ios9后打开百度、高德地图需要以下配置
在info.plist添加白名单
<key>LSApplicationQueriesSchemes</key>
<array>
<string>baidumap</string>
<string>iosamap</string>
</array>
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
设置状态栏样式
1 修改info.plist文件,让UIApplication设置样式
添加 View controller-based status bar appearance 并设置为 NO
2 设置样式
在appdelegate中application.statusBarStyle = UIStatusBarStyleLightContent;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Provisioning profile is expiring warning
~/Library/MobileDevice/Provisioning Profiles/
删除掉所有的profile在重新下载
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
directory not found for option ‘-L
解决方法:
修改路径:选择项目名称----->Targets----->Build Settings----->Search Paths----->Library Search Paths
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
==15481==ERROR: AddressSanitizer: heap-buffer-overflow
edit scheme…->Run->Diagnostics->取消 Enable Address Sanitizer
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Scale:拉伸图片
Aspect:图片长宽的比例,保持图形的长宽比,保持图片不变形。
Aspect Fill:在保持长宽比的前提下,缩放图片,使图片充满容器。
Aspect Fit:在保持长宽比的前提下,缩放图片,使得图片在容器内完整显示出来。
Scale to Fill: 缩放图片,使图片充满容器。图片未必保持长宽比例协调,有可能会拉伸至变形。
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
桌面图标通知
// 注册推送, 用于iOS8以及iOS8之后的系统
if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) {
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert) categories:nil];
[application registerUserNotificationSettings:settings];
}
application.applicationIconBadgeNumber = 1;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
The identity used to sign the executable is no longer valid.
步骤:
- 打开Xcode配置(Xcode -> Preferences...)
- 选择Accounts页面,选中你的Apple ID,点右下方的「View Detail...」按钮
- 点击左下角的刷新按钮,等待刷新完成,点「Done」按钮,关闭Xcode配置窗口
- 重新编译运行项目,若出现修复窗口,一路点「Fix Issue」按钮
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
设备的provis文件地址
/Users/mashangyouqian/Library/MobileDevice/Provisioning Profiles
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
This application is modifying the autolayout engine from a background thread, which can lead to engine corruption and weird crashes. This will cause an exception in a future release
把需要更新UI的放在的主线程就好了
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
The identity used to sign the executable is no longer valid
删掉~/Library/MobileDevice/Provisioning Profiles/ 下所有文件, 在重新下载
下载:Xcode->Preference...->AppleID->ViewDetails->DownloadAll
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-(void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
// 开启系统返回手势
if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
self.navigationController.interactivePopGestureRecognizer.enabled = YES;
}
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
// 禁用系统返回手势
if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
self.navigationController.interactivePopGestureRecognizer.enabled = NO;
}
}
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#pragma mark - tap和didSelect冲突解决
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
if ([NSStringFromClass([touch.view class]) isEqualToString:@"UITableViewCellContentView"]) {
// 如果返回NO,则gesture recognizer会忽略此触摸事件
return NO;
}
return YES;
}
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CUICatalog: Invalid asset name supplied: (null)
原因imageNamed为空
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
iOS项目工程,添加一个c文件,编译报错
解决方案:
将#import用包裹起来
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
svn 提交 is out of date
update
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
给 App 瘦身的另一个手段是提交 Bitcode 给 Apple,而不是最终的二进制。Bitcode 是 LLVM 的中间码,在编译器更新时,Apple 可以用你之前提交的 Bitcode 进行优化,这样你就不必在编译器更新后再次提交你的 app,也能享受到编译器改进所带来的好处。Bitcode 支持在新项目中是默认开启的,没有特别理由的话,你也不需要将它特意关掉。
视频 app 的画中画模式相对简单一些,如果你使用 AVPlayerLayer 来播放视频的话,那什么都不用做就已经支持了。但如果你之前选择的方案是 MPMoviePlayerViewController 的话,你可能也需要尽早迁移到 AVKit 的框架下来,因为 Media Player 将在 iOS 9 被标记为 deprecated 并不再继续维护。
滑动覆盖和分割视图的 app 会使用 iOS 8 引入的 Size Class 中的 Compact Width 和 Regular Height 的设定,配合上 AutoLayout 来进行布局。
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
通知只在主线程发送。
在init中注册,在dealloc中注销。
ghthouse是一个很好的错误追踪工具。OmniOutliner,我在这上面可以找到一堆事情去做。
如果你崩溃了,最好使用僵尸Zombies工具。
真实的代码质量远比别人怎么看我更重要。
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
The operation couldn’t be completed
退出Xcode重启
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
VVDocumenter-Xcode失效问题解决(如果这么弄都不行, 就删掉重来就OK)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app‘s Info.plist file.
在info.plist中添加
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
iOS - is missing from working copy
解决方案:
1.打开终端
2.cd 到警告所提示的文件夹下
3.执行命令svn rm --force 丢失文件的名称
4.回车
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
批量更新Xcode插件
find ~/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins -name Info.plist -maxdepth 3 | xargs -I{} defaults write {} DVTPlugInCompatibilityUUIDs -array-add `defaults read /Applications/Xcode.app/Contents/Info DVTPlugInCompatibilityUUID`
以上是关于15/10-16/6开发笔记的主要内容,如果未能解决你的问题,请参考以下文章