ios问题解决总结.docx_第1页
ios问题解决总结.docx_第2页
ios问题解决总结.docx_第3页
ios问题解决总结.docx_第4页
ios问题解决总结.docx_第5页
已阅读5页,还剩4页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

项目开始前工作1.管理第三方库的cocoapods安装导入 安装使用(/gf771115/article/details/50403253); 如果在pod install、或者pod update时,不想升级specs库,可以增加忽略参数pod install -no-repo-updatepod update -no-repo-update2.tabbar构建 1)跳子页面隐藏的时候隐藏了导航栏,但下面出现白条无法隐藏,可创建UITabBarController类,在类中调用UINavigationControllerDelegate 中willShowViewController和didShowViewController方法; 2)子视图从左往右拖回到根视图,将每个视图控制器的UINavigationController加入代理,在第一个子视图加入self.navigationCeractivePopGestureRecognizer.delegate = self;调用- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer方法3)ios9系统后不支持http,在.plist文件中加入App Transport Security Settings类型dictionary,在其下添加Allow Arbitrary Loads改成yes;4)删除storyboad,删除自动生成的sroryboad和launch.xib,在Target-App Icons中的Launch Screen File修改一个xib5) Bundle display name编写自己项目在手机桌面显示的名字项目问题解决1) ios9后提示框更新 UIAlertController *alert=UIAlertController alertControllerWithTitle:nil message:关注成功 preferredStyle:UIAlertControllerStyleAlert; UIAlertAction *action=UIAlertAction actionWithTitle:确认 style:UIAlertActionStyleDefault handler:(UIAlertAction * _Nonnull action) ; alert addAction:action; /定义第一个输入框; alertController addTextFieldWithConfigurationHandler:(UITextField * _Nonnull textField) ;self presentViewController:alert animated:YES completion:nil; 2)一串字符串出现多彩,不同字体方法 NSString *str2=NSString stringWithFormat: %,user.houseprice; NSString *sr2=NSString stringWithFormat:%元/平方米,str2; NSMutableAttributedString *money=NSMutableAttributedString allocinitWithString:sr2; money addAttribute:NSForegroundColorAttributeName value:UIColor redColor range:NSMakeRange(0,str2 length); money addAttribute:NSFontAttributeName value:UIFont fontWithName:Helvetica-Bold size:ConvertBySize(17) range:NSMakeRange(0, str2 length); 3)图片显示拉伸变形,将显示图片的UI加在scrollview上,设置contentMode(imagevew.contentMode=UIViewContentModeScaleAspectFill;),再设置UIScrollview的contentsize; 4)对比两个日期时间 -(NSString *)compareTimeWithDate:(NSString *)timedate /首先创建格式化对象 NSString *str=NSString string; NSDateFormatter *dateFormatter = NSDateFormatter alloc init; dateFormatter setDateFormat:yyyy/MM/dd HH:mm:ss; /然后创建日期对象 NSDate *date1 = dateFormatter dateFromString:timedate; NSDate *date = NSDate date; /计算时间间隔(单位是秒) NSTimeInterval time = date1 timeIntervalSinceDate:date; /计算天数、时、分、秒 int days = -(int)time)/(3600*24); int hours = -(int)time)%(3600*24)/3600; int minutes = -(int)time)%(3600*24)%3600/60; int seconds = -(int)time)%(3600*24)%3600%60; if (hours!=0) NSDateFormatter *fomatter=NSDateFormatter allocinit; fomatter setDateFormat:yyyy/MM/dd; NSString *str1=fomatter stringFromDate:date; NSString *str2=fomatter stringFromDate:date1; date=fomatter dateFromString:str1; date1=fomatter dateFromString:str2; BOOL isNeed = date1 compare:date=NSOrderedSame; if (isNeed=NO) str=NSString stringWithFormat:%i天前,days+1; else if(isNeed=YES) if (hours10) str=今天; else str=NSString stringWithFormat:%i小时前,hours; else if (minutes!=0) str=NSString stringWithFormat:%i分前,minutes; else if (seconds!=0 | seconds0) str=NSString stringWithFormat:%i秒前,seconds; else str=NSString stringWithFormat:%i秒前,1; /NSString *dateContent = NSString alloc initWithFormat:仅剩%i天%i小时%i分%i秒,days,hours,minutes,seconds; return str; 5)设置适应不同键盘高度的方法 设置监听NSNotificationCenter defaultCenter addObserver:self selector:selector(keyboardWillChangeFrame:) name:UIKeyboardWillShowNotification object:nil; 实现方法 - (void)keyboardWillChangeFrame:(NSNotification *)notification NSDictionary *info = notification userInfo; /CGFloat duration = info objectForKey:UIKeyboardAnimationDurationUserInfoKey floatValue; /获取高度 NSValue *value = info objectForKey:UIKeyboardBoundsUserInfoKey;/关键的一句,网上关于获取键盘高度的解决办法,多到这句就over了。系统宏定义的UIKeyboardBoundsUserInfoKey等测试都不能获取正确的值。不知道为什么。 CGSize keyboardSize = value CGRectValue.size; NSLog(横屏%f,keyboardSize.height); UIView animateWithDuration:0.7 animations: _inputView.frame=CGRectMake(0, SCREEN_HEIGHT-44-keyboardSize.height, SCREEN_WIDTH, 44); ; 6)监听UItextfield字符长度 给textfield加 _inputTF addTarget:self action:selector(actionNickTF:) forControlEvents:UIControlEventEditingChanged; 实现方法-(void)actionNickTF:(UITextField *)textField NSLog(%lu,(unsigned long)textField.text.length); /截取到多长 if (textField.text.length = 9) NSRange range2 = NSMakeRange(0, 8); NSString * str = textField.text substringWithRange:range2; textField.text = str; 7)上传特殊字符串(包括表情),使用第三方库Base64_textView.text base64EncodedString编码加密, _textView.text base64DecodedString解码 8)解决textview起始输出字符位置_textView.selectedRange=NSMakeRange(0,0) ; /起始位置 9)自定义uilabel的字体间隔 NSMutableAttributedString * attributedString1 = NSMutableAttributedString alloc initWithString:details; NSMutableParagraphStyle * paragraphStyle1 = NSMutableParagraphStyle alloc init; paragraphStyle1 setLineSpacing:8;attributedString1 addAttribute:NSParagraphStyleAttributeName value:paragraphStyle1 range:NSMakeRange(0, details length); 10)流媒体视频播放,模拟器调试出现崩溃,使用真机调试以真机为主 11)navigation status bar显示时间栏默认为黑色,需要在.plist文件中加入View controller-based status bar appearance 设置为yes,然后在根视图的viewdidload或willappear中加self.navigationController.navigationBar.barStyle = UIBarStyleBlack; 12)数组越界的问题(常见情况是:先进网络请求的语句,但是在下面语句紧接着就使用了接收网络数据的NSArray或者是 NSMutableArray),对个元素个数为0的数组进行 objectAtIndex:操作,导致数组越界,解决方法是在从数组中取元素的时候,对数组进array count判断;保证数组中元素个数不为0,然后再对数组进行操作。注:可变数组如果没用到addObject方法,不能使用remove做清空数组操作,否则会导致崩溃 13) 在IOS7中UINavigationController中使用UITextView或者 UIScrollView的时候,文本的对齐方式,垂直方向的对齐方式是居中对齐,不是上对齐,需要在viewDidlLoad里面添加: automaticallyAdjustsScrollViewInsetsif(UIDevice currentDevice systemVersion floatValue = 7.0)在使用UIScrollView的时候也会出现偏移。 14) UITableView 定位到某个分区或者某NSIndexPath *scrollIndexPath = NSIndexPath indexPathForRow:0 inSection:3;_tableView scrollToRowAtIndexPath:scrollIndexPath atScrollPosition:UITableViewScrollPositionTop animated:YES; 15)iOS9后不能自动加入.pch点文件,首先创建.pch文件放到项目文件中,然后在Target-Build Settings搜索Prefix Header填写pch文件地址,再将上面那一项改为YES 16)当某些控件没有响应操作是,设置其或者它的父视图的可交互性userInteractionEnabled。 17) 如果在使用第三方静态库如ShareSDK的时候出现错误Undefined symbols for architecture arm64:或者是X86-64,当前的静态库不支持64page7image5152 page7image5312 page7image5632 位,需要在Build Settings下面,删除Valid Architectures 下的arm64 ,并且改Build Active Architecture Only改为NO. 18) 如果UITableViewCell,didSelect方法不走,其他代理法都走,那么是有手势截获了UITabelViewCell的didSelect事件 19) 上传程序的时候出现Missing Screenshot”,可能原因是创建工程的时 候选择的是混合工程,但是没有iPad的截图 20) 遇到错误,ld: building for iOS Simulator, but linking against dylib built for MacOSX file /Applications/Xcode.app/Contents/Developer/Library/Frameworks/XCTest.framework/XCTest for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)1把下面的XCTest.framework删掉,2然后把测试工程.m文件右边的target勾选掉21) 控制table的分割线长短 self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone; self.tableView.separatorColor = UIColor colorWith

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论