iOS常见问题笔记总结这是本人开发中遇见的一些常见问题处理方法的总结笔记,包括http访问配置、Alcatraz插件安装、最新cocoapod安装、真机运行出错等许多与参考笔记总结,希望对大家有所帮助

开发总结:

快捷键打开浏览器控制台cmd+option+J

强制退出任务或者打开任务栏:command+option+SSC(打开任务栏)command+option+shift+ESC(强制退出任务)

 

Xcode8关闭输出日志http://blog.csdn.net/u011467458/article/details/52571353

快捷多行注释:cmd+option+/

 

工具下载

           SVN工具下载:

http://bbs.feng.com/read-htm-tid-7936664.html

配置PCH文件

打开TAGERS-----------Build Setting (All options)文件下搜索:prefixPrefix Header点击配置:

$(SRCROOT)/PCH文件上个目录名/PCH.pch

    http://blog.sina.com.cn/s/blog_801997310102v7q2.html

 

1.Xcode插件管理:  Alcatraz

http://www.jianshu.com/p/7a2484123bf6//安装等相关操作步骤网址(1)

http://www.mamicode.com/info-detail-976060.html//安装等相关操作步骤网址(2)

 

2.网络请求

Http请求数据不下来报错:

(1)Error Domain=NSURLErrorDomain Code=-1022 "The resource couldnot be loaded because the App Transport Security policy requires the use of asecure connection." UserInfo={NSUnderlyingError=0x7fce0c9ac400 {ErrorDomain=kCFErrorDomainCFNetwork Code=-1022 "The resource could not beloaded because the App Transport Security policy requires the use of a secureconnection." UserInfo={NSErrorFailingURLStringKey=http://www.baidu.com/,NSLocalizedDescription=The resource could not be loaded because the AppTransport Security policy requires the use of a secure connection.,NSErrorFailingURLKey=http://www.baidu.com/}},NSErrorFailingURLStringKey=http://www.baidu.com/,NSErrorFailingURLKey=http://www.baidu.com/, NSLocalizedDescription=The resourcecould not be loaded because the App Transport Security policy requires the useof a secure connection.}

配置https:                                                      

 解决方法:http://www.tuicool.com/articles/IjYNzaI

2)网络请求遇到错误

原因:后台接口没有传递jsion类型接口参数

解决方法:添加

manager.requestSerializer =[AFHTTPRequestSerializer serializer];

 

http://stackoverflow.com/questions/26235270/error-domain-com-alamofire-error-serialization-response-code-1011-request-fail

 

 

3)网络请求错误原因:

主要是后台错误,让后台去调试。     ··

AFNetworking3.0的使用 :http://www.jianshu.com/p/11bb0d4dc649

          

           3.安装cocoapods

 

           http://www.cnblogs.com/jys509/p/4839803.html    安装指南网址

http://www.cnblogs.com/jys509/p/4839803.html  // 安装最新cocoapods网址

http://www.cnblogs.com/brycezhang/p/3675670.html//cocoapod安装升级更新

安装cocoapods出现错误:[!] /usr/local/bin/git clonehttps://github.com/CocoaPods/Specs.git master
Cloning into'master'...
error: RPC failed; result=56, HTTP code=200
fatal: The remote end hung upunexpectedly
fatal: early EOF
fatal: index-pack failed

解决方法:http://www.cnblogs.com/hankkk/p/5703050.html

回滚到指定版本:或者卸载http://blog.csdn.net/majiakun1/article/details/51499606

最新cocoaPod的使用

1,创建Podfile文件

           cd工程目录

           VimPodfile

点击 i进行编辑(可添加要用的点三方文件):举例

A.

platform:ios,"7.0"

 

target"ZJmicroblog" do

 

pod'Masonry', '~> 1.0.0'

end

然后

点击 ESC 键完成最后输入 :wq退出(结束当前操作,并跳到项目目录下)

让后 pod install 下载文件即可

B.直接完成

点击 ESC 键完成最后输入wq退出

 

查看cocoapod版本

     在终端输入   pod --version

C.cocoaPod 下载最新文件

    

platform  :ios,’所支持的最低平台(7.0

target ’ 项目名字

pod ‘所下载的第三方名字,‘~>版本号(3.0)’

end  结束

 

podFile出现这种警告:

http://blog.csdn.net/m372897500/article/details/50805854

Your Podfile has had smart quotes sanitised. To avoidissues in the future, you should not use TextEdit for editing it. If you arenot using TextEdit, you should turn off smart quotes in your editor of choice.解决办法:打开工程,打开podfile文件使用Xcode进行编辑,添加第三方库文件   

 

 

 

           4.当在真机运行中出现

                    

时,解决方法在Xcode中进行如下操作:

           修改DeDeployment Target到相应的系统即可

5. http://blog.sina.com.cn/s/blog_68e753f70100r3w5.html//真机调试相关参考   删除项目里面证书文件:

          http://blog.csdn.net/xyxjn/article/details/38081177   手动删除

xcode5 provisioning profile path ~/Library/MobileDevice/ProvisioningProfiles

 

6.证书运行出现?????

一般为系统根证书过期和登录证书过期

7.证书的相关问题帮助文档:

https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/AppDistributionGuide/MaintainingProfiles/MaintainingProfiles.html#//apple_ref/doc/uid/TP40012582-CH30-SW28

8.Xcode运行出现以下问题及解决办法:

                    

9.图标库

           http://www.iconfont.cn/ //阿里巴巴矢量图

10.

运行结果一样,不理解,有时间研究;朋友的解释:

补充:

C函数执行后会释放空间(释放空间的含义是指针不再指向而不是更改了那一块内存的值)

下一个函数使用堆内存的时候仍然使用那块堆内存(因为下一个函数认为上一个函数执行完成释放了空间,所以它接着用)

11.导航栏出现延时状况

     解决方法:[[UINavigationBarappearance]setTranslucent:NO];

     参考说明:

http://www.cocoachina.com/bbs/read.php?tid=153910

 

12.tableView不走代理方法

当不走tableVIew代理中didSelect方法时,若存在

-(void)touchesBegan:(NSSet<UITouch *>*)touches withEvent:(UIEvent *)event这个方法时,优先级touchesBegan高于tableVIew 代理中didSelect方法所以不走这个代理方法;

 

 

13.正则表达式的学习

学习网站

http://www.admin10000.com/document/5944.html  //正则表达式

http://blog.csdn.net/cloverzhu/article/details/50038643    //判断邮箱,身份证,手机号验证,正则表达式 

 

一、什么是正则表达式

 

  正则表达式,又称正规表示法,是对字符串操作的一种逻辑公式。正则表达式可以检测给定的字符串是否符合我们定义的逻辑,也可以从字符串中获取我们想要的特定部分。它可以迅速地用极简单的方式达到字符串的复杂控制。

 

 二、正则表达式的语法

 

  看一个过滤纯数字的例子

 

-(BOOL)validateNumber:(NSString *) textString

{

    NSString* number=@"^[0-9]+$";

    NSPredicate *numberPre = [NSPredicatepredicateWithFormat:@"SELF MATCHES %@",number];

    return [numberPreevaluateWithObject:textString];

}

 

  其中下述语句就是一个正则表达式

 

@"^[0-9]+$"

 

  它代表了字符串中只能包含>=1个0-9的数字,语法是不是有一些怪异?

 

  下面我们先撇开iOS中的正则表达式的语法,用通俗的正则表达式语法来为介绍一下。(iOS语法与通俗的正则表达式语法相同,不同在于对转义字符的处理上(语言类的都相同))

 

  语法:

 

  首先,特殊符号’^'和’$'。他们的作用是分别指出一个字符串的开始和结束。eg:

 

  “^one”:表示所有以”one”开始的字符串(”one cat”,”one123″,·····);

 

  类似于:-(BOOL)hasPrefix:(NSString *)aString;

 

  “adog$”:表示所以以”a dog”结尾的字符串(”it is a dog”,·····);

 

  类似于:- (BOOL)hasSuffix:(NSString*)aString;

 

  “^apple$”:表示开始和结尾都是”apple”的字符串,这个是唯一的~;

 

  “banana”:表示任何包含”banana”的字符串。

 

  类似于iOS8的新方法- (BOOL)containsString:(NSString *)aString,搜索子串用的。

 

  ‘*’,’+'和’?'这三个符号,表示一个或N个字符重复出现的次数。它们分别表示“没有或更多”([0,+∞]取整),“一次或更多”([1,+∞]取整),“没有或一次”([0,1]取整)。下面是几个例子:

 

  “ab*”:表示一个字符串有一个a后面跟着零个或若干个b(”a”, “ab”, “abbb”,……);

 

  “ab+”:表示一个字符串有一个a后面跟着至少一个b或者更多( ”ab”, “abbb”,……);

 

  “ab?”:表示一个字符串有一个a后面跟着零个或者一个b( ”a”, “ab”);

 

  “a?b+$”:表示在字符串的末尾有零个或一个a跟着一个或几个b( ”b”, “ab”,”bb”,”abb”,……)。

 

  可以用大括号括起来({}),表示一个重复的具体范围。

 

14.谓词NSPredicate(查询)

 

 

15.iPhone5sS 不能同步的原因:第三方软件的影响,

·bbs.app111.com/thread-552394-1-1.htm

16.刷新指定分区的指定cell http://leopard168.blog.163.com/blog/static/16847184420148229221893/  tableView 刷新 collectionView原理相同

17. 解决Xcode 9.2系统真机测试时出现 could not find developerdisk image问题

解决Xcode在ipad/iphone9.2 系统真机测试时出现could not find developer disk image问题

 

方法1:拷贝这个文件(http://download.csdn.net/detail/cvbtvbwu/9340467)到/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport,然后重新启动xcode(完全退出)就可以了。

方法2:更新Xcode到7.2版本。

18.当整机运行出现 “Please verifythat your device’s clock is properly set, and that your signi ”时,原因是  : yoursigning certificate is not expired.就是你的证书无效了,你去“钥匙访问串”里把无效的证书删除后,重新安装一个有效的就可以了

 

http://bbs.csdn.net/topics/391839005 参考地址

19.当cocoapods 出现     

  diff: /../Podfile.lock: No such file ordirectory 

    diff: Manifest.lock: No such file ordirectory  

    error: The sandbox is not in sync with thePodfile.lock. Run 'pod install' or update your CocoaPods installation.`   问题时的解决方法:

关闭当前的工作空间,删除掉文件夹中的workspace,然后重新pod install,install完成之后,通过workspace打开工作空间 

参考方法:http://blog.csdn.net/willyang519/article/details/40744081

20.设置button文字的位置对齐方式

buttonEdit.contentHorizontalAlignment=UIControlContentHorizontalAlignmentLeft;//水平向左;垂直类似

21.开发崩溃:thread 1:exc_bad_access(code=1,adress=0x0) 

造成崩溃及解决原因

原因:对象木有创建;

http://www.ithao123.cn/content-42653.html

22.UIButton 标题设置多行显示  self.buttonOneKey.titleLabel.numberOfLines=0;

23 系统方法实现图文混排

http://blog.sina.com.cn/s/blog_6f1a34260101ptox.html

 

24.项目运行报错ld: 3 duplicate symbols for architecture x86_64

clang: error:linker command failed with exit code 1 (use -v to see invocation) //文件重复

 

25.使用AlertController出现的报警

_BSMachError:(os/kern) invalid capability (20)

原因:

http://blog.csdn.net/qtds8810/article/details/50267755

 

26.读取本地Json文件出现错误ErrorDomain=NSCocoaErrorDomain Code=3840 "JSON text did not start with array orobject and option to allow fragments not set."UserInfo={NSDebugDescription=JSON text did not start with array or object andoption to allow fragments not set.}

 

 

27.判断APP当前版本和版本升级

http://www.2cto.com/kf/201501/368967.html

 

28.字符串转字典

 

NSstring      *  str   = @"623630666332643437656662656130373335383835313236626138633730326366316361363662333766613433623037666464636230333436396437643936343735633836366334";

 

 

问题 那么如何转换成字典活着数组对象

NSError*error = nil;

NSDictionary*string2dic = [NSJSONSerialization JSONObjectWithData: [strdataUsingEncoding:NSUTF8StringEncoding]

options:NSJSONReadingMutableContainers

 

error:&error];

 

 

29.

  ,销量高低选择http://code4app.com/forum.php?mod=viewthread&tid=9104&extra=page%3D1%26filter%3Dsortid%26sortid%3D1

30.tableVIew运行崩溃原因:

Assertion failure in-[UITableView _configureCellForDisplay:forIndexPath:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3512.30.14/UITableView.m:7962 原因是cell为空,需要创建生成

 

 

30出现警告

Conflicting parameter types inimplementation of'commomDealgetHeightCountWithContenStr:withControlsWidth:withControlsFont:':'__strong id' vs 'CGFloat' (aka 'double')

类型和系统类型不匹配,最好查看系统类型,调整类型一致

 

31.IPv6网络配置

http://blog.csdn.net/potato512/article/details/51680203

 

 

32.粘贴复制:http://www.cnblogs.com/lzjsky/archive/2013/03/18/2966223.html

 

33.项目中警告类出现红色的文件:

解决办法:清楚缓存,若哈木有解决,清楚缓存后关闭项目,重新打开即可解决。

 

34.Swift学习: swift.org

 

 

35.git使用

从git地址下载资料:

1.    打开终端 后:cd Document //保存资料所在位置 (该处为文稿位置)

输入git地址:git clone https://code.csdn.net/cd_ysxy/ase_ios.git

(git地址)

2.    输入账户和密码回车即可自行下载

 

 

36.将图片放在Images.xcassets与直接放在源文件的区别:

http://blog.csdn.net/u010622887/article/details/47272627

http://blog.csdn.net/u010105969/article/details/51004243

 

 

37.将语言设置问中文:

       在plist文件中找到Localization native development region选项中 设置为China即可实现为中文

 

方法二:

此步骤也能实现语言汉化

 

38.tabbar出现标题重复的问题:

self.title 是设置导航栏和tabbar的标题;

self.navgationItem.title 是只设置导航栏的标题

 

 

39.UIlabel的行间距的设置

 

customString=[[NSMutableAttributedString alloc]initWithString:[NSStringstringWithFormat:@"%@%@",firstString,secondString]];

       

       NSMutableParagraphStyle *style=[[NSMutableParagraphStyle alloc]init];

       style.headIndent=0;//整体缩进(首行除外)

       style.firstLineHeadIndent=30;//首段缩进

        style.lineSpacing=linespace; //字体的行间距

       

       

       [customString addAttribute:NSFontAttributeName value:[UIFontsystemFontOfSize:fontSize] range:NSMakeRange(firstString.length,secondString.length)]; //设置文字的大小

       [customString addAttribute:NSParagraphStyleAttributeName value:stylerange:NSMakeRange(0, customString.length)];

 

参考网址:http://www.tuicool.com/articles/7BJjYj

                    http://www.tuicool.com/articles/QZ3If2

 

 

40.ios 函数库学习

http://blog.csdn.net/gf771115/article/details/7860414

http://www.cnblogs.com/On1Key/p/5454348.html

 

 

41. setNeedsLayout、 layoutIfNeeded 和 layoutSubviews 方法之间的关系解释

http://www.cocoachina.com/bbs/read.php?tid=111832

http://www.open-open.com/lib/view/open1438053045972.html

 

 

42.导航栏相关的属性设置

 

http://www.jianshu.com/p/aa547432eae0

 

43.定时器的使用

http://blog.csdn.net/chadeltu/article/details/44976527

 

 

45.ios 10系统打开相册出现奔溃原因:需要在plist文件里面配置访问信息

 

解决方案

设置了plist文件中的一些访问权限参数,如下http://blog.csdn.net/wxs0124/article/details/52540528

 

46。将代码存在Xocde里面

http://blog.csdn.net/sakulafly/article/details/46404393

在Xcode选择

将所需保存的代码如,然后编辑,最后保存即可,

在所需使用的地方

 

47.collectionView实现头部分区和底部分区奔溃:dequeueReusableViewOfKind:withIdentifier:forIndexPath:viewCategory:],/BuildRoot/Library/Caches/com.

 原因没有找到注册的标识符,解决办法:

定义一个全局的标识符:然后在注册和使用中使用该标识符

 

http://zhidao.baidu.com/link?url=EgtAZV1iXX2AaPDTXfg6UNo-VAchIBEsaaT48tW1nUOAPwSP0bF4fOZvBcH7WdrcLY1cyzZKVWdkgb_vyW8Y4B2nYMRRsld-uctcw3cJLq_

 

猜你喜欢

转载自blog.csdn.net/xiaoxiajiayou/article/details/53890890