iOS错误总结
1.
00006 请求的url错误
2.
00055 是缺少下面两行代码
_instance.requestSerializer = [AFJSONRequestSerializer serializer];
_instance.responseSerializer = [AFHTTPResponseSerializer serializer];
3.tableView代理方法不执行什么原因
1.设置代理 2.tableview的frame 3.代理方法return numberOfRows的返回值 4.数据源没有值5.子类继承自父类时,代理方法没有进行重写,父类的分组的个数已经设置为0,继承,方法的重写(方法名参数相同)方法的重载(方法名相同,但是参数列表不一样)一定要引起相关的重视。
4.
更新pod常见问题,新版本替换老版本出现的问题
1》先更新,清楚缓存 sudo rm -fr ~/.cocoapods/repos/master
2》网络好的时候,更新完全
5.
如果pod出现了重大错误可以将其整体删掉
Podfile Podfile.lock Pods RobotFamily.xcworkspace 然后重新进行pod即可
6.枚举类型的定义,方便开发者调用
typedef enum : NSUInteger{
RequestTypeGet,
RequestTypePost,
}RequestType;
错误代码是-1009网络连接失败
8.
创建数组记得初始化,但是直接set方法里面传递过来的数组可以直接使用
9.
@property(nonatomic,strong)RFBaseTypeTableViewController *baseVc;
控制器只能自己进行管理,控件有个subViews的数组可以进行强引用所以使用weak,但是创建的控制器放在里面必须创建强引用
View里面的控件创建之后必须进行强引用,应为没有subViews对其进行强引用,保证创建出来的View一直都用,push出去的控制器会一直进行强引用,因为有viewControllers这个数组进行强引用
下面我会这对这个时间进行详细的说明:http://www.cnblogs.com/chaoyueME/p/5915955.html
10.
检测并更新新版本库:update。可以通过查看Pods中已过期的第三方开源库。install & update区别: 例如:Podfile中,,而未指定此开源库版本。install,如果SVProgressHUD已存在Pods中,则直接使用它。但是,update,会重新下载最新版本到Pods中
11.
取消tableView以及scrollView适应-64
12.
设置textField左边按钮的间距
UIView *leftVie = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 10, 100)];
textF.leftView = leftVie;
//设置左边view的显示方式
textF.leftViewMode = UITextFieldViewModeAlways;
13.
xcode升级之后可以在cornerstore中整体的复制版本,保留之前的版本,具体做法,点击之前的版本,右键,copy保留到对应的文件夹即可
14.
Can't find keyplane that supports type 4 for keyboard iPhone-PortraitTruffle-NumberPad; using 2425442915_PortraitTruffle_iPhone-Simple-Pad_Default
目前没有解决办法,但是不影响使用
15.
xcode8.0打开相册秒崩的解决办法
<key>NSCameraUsageDescription</key>
<string>cameraDesciption</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>photoLibraryDesciption</string>
遗留问题:
Class PLBuildVersion is implemented in both /Applications/Xcode8.0.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/AssetsLibraryServices.framework/AssetsLibraryServices (0x11b056910) and /Applications/Xcode8.0.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/PhotoLibraryServices.framework/PhotoLibraryServices (0x11a783210). One of the two will be used. Which one is undefined.
16.
UISwitch不能设置宽高
self.switchView.transform = CGAffineTransformMakeScale(0.5, 0.5);只能更改transform
但是很难设置对其
//设置开关颜色
self.switchView.onTintColor= [UIColor blueColor];
通常使用通过UIButton进行模
17.
SVN更新素材,除了上面的两个Applcon和contents.json 剩下的都可以在svn上面直接进行删除,提交,更换
18.
子类继承时,切记不要写与父类相同的方法名,不然会覆盖父类的相关方法
19.
屏幕适配可以通过masonry或是snipKit,也可以是通过frame的比例进行自动布局,在layoutSubviews(方法里面切记不要创建元素,不要设置约束,约束重定义会报错)的方法里面
20.监听事件首选是addTarget(系统默认有好多已经写好的键值就是为了减少代理和通知的使用)的方法,其次才是代理和kvo
1.减少过期方法的警告
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
过期方法写在这里
#pragma clang diagnostic pop
2.pch的路径
$(SRCROOT)/$(PRODUCT_NAME)/PrefixHeader.pch
3.获取沙河路径的方法
//1,获取沙盒目录路径的函数:
NSString *homeDir = NSHomeDirectory();
//2,获取Documents目录路径的方法:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);
NSString *docDir = [paths objectAtIndex:0];
//3,获取Caches目录路径的方法:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSCachesDirectory,NSUserDomainMask,YES);
NSString *cachesDir = [paths objectAtIndex:0];
//4,获取tmp目录路径的方法:
NSString *tmpDir = NSTemporaryDirectory();
4.TPKeyboardAvoiding使用
导入头文件 TPKeyboardAvoidingScrollView.h
增加系统方法
- (void)loadView{
[super loadView];
self.view = [[TPKeyboardAvoidingScrollView alloc]initWithFrame:CGRectMake(0, 0, 屏幕的宽度, 屏幕的高度)];
}
5.打开Apache的终端输入语句
sudo apachectl -k start
6.pod
pod 'MBProgressHUDExtensions', '~> 0.0.1'
此版本有直接showMessage的方法,或者直接进行手动的导入
7.pod的版本带上,以免版本更新,重新pod出错
8._和self的区别
前者调用该类的setter或getter方法,后者直接获取自己的实例变量。setter方法里面的retainCount会进行+1,后者不会
9.程序杀死或推到后台applicationDidEndBackground(application:UIApplication){
}
10.插入或者替换原来的数据的数据库SQL语句
11.一个待解觉问题
12.
Controller
self.tableView reloadData];
View
self reloadData];
13
iOS开发 tableview滚动到最后一行为什么有半行无法显示?
做了一个类似电话簿的应用。添加页面添加新联系人返回主页面时会自动加到最后一行显示。现在想实现加完回到主界面时自动滚到新加的这一项。用的以下方法,但是总是有半行在屏幕下方滚不出来,求解。
[self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:[telListData count]-1 inSection:0] atScrollPosition:UITableViewScrollPositionBottom animated:NO];
tableview 的高度 大于 了self.view 的高度了;
14.数据刷新完成之后想立即进行滚动制定的行应当先进性刷新再进行滚动
1.footerView上面按钮的点击事件没有响应,如果是分组的组头组尾可能是没有写组高
若是整个tableView的footerView或者是headerView,就是没有进行frame的设置
2.统一使用View可能设置不上,虽然他们的地址是相同的
ViewController设置View的backgroundColor
self.view.backgroundColor = [UIColor purpleColor];
tableViewController设置backgroundColor
self.tableView.backgroundColor = [UIColor purpleColor];
3.
懒加载继承记得改写方法名,(拷贝时出错)方法虽然不会出错,但是一直都不会被调用
4.
svn黄叹号可以直接删除掉(橘黄色)delete
5.
在Controller里面的cell里面的控件不能进行懒加载,可以在cell的内部进行,但是懒加载就会只创建一次,但是每个cell都需要,结果就是导致Controller进不去,不好判断原因
6.
pod 'MBProgressHUDExtensions', '~> 0.0.1' 这个里面有ShowMessage方法
7.
关于使用tableView分组技术的小问题
解决方法:
在tableViewController里面设置样式
-(instancetype)init{
self = [super initWithStyle:UITableViewStyleGrouped];
return self;
}
//设置间距 近似于返回0,但是如果不进行设置就会返回12
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
return 0.01;
}
8.push之前,类的属性赋值直接给属性赋值就好了,但是push之后再赋值就得冲写set方法了
9.
不要让一个类承担过多的指责
10.处理器
armv7 arm64(真机) i386 x86_6(模拟器)
11.快捷打印
NSLog(res?@"插入成功":@"插入失败");
12.WWDR证书过期
http://developer.apple.com/certificationauthority/AppleWWDRCA.cer
新的证书网址,下载下来 ,点击安装
我的钥匙串,显示 - > 显示过期证书 - > 点击系统 -> 删除过期的证书即可
13.pch的路径
$(SRCROOT)/$(PRODUCT_NAME)
14.一下代码约束报错
[imageRight mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(mySelf.contentView.mas_right).with.offset(-kFitW(20));
make.top.equalTo(mySelf.contentView.mas_top).with.offset(0);
make.width.mas_equalTo(kFitW(8));
make.height.mas_equalTo(80);
}];
[imageV mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(imageRight.mas_leading).with.offset(-kFitW(3));
make.centerY.mas_equalTo(mySelf.contentView.mas_centerY);
make.width.mas_equalTo(60);
make.height.mas_equalTo(60);
}];
报错信息:+[NSLayoutConstraint constraintWithItem:attribute:relatedBy:toItem:attribute:multiplier:constant:]: A constraint cannot be made between a leading/trailing attribute and a right/left attribute. Use leading/trailing for both or neither.'
原因:
原因:自动布局 属性对应错误
Left 对应right
leading 对应traing
15:
Terminating app due to uncaught exception 'Cannot Install Constraint', reason: 'No common superview between views
原因: 没有添加到父视图上
16:可以把单独的模块放到.h中,导入pch文件中,这样方便阅读
color.h 等等
17:
将文件保存到沙盒中
NSString * DocumentsPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
//文件管理器
NSFileManager *fileManager = [NSFileManager defaultManager];
//把刚刚图片转换的data对象拷贝至沙盒中 并保存为image.png
[fileManager createDirectoryAtPath:DocumentsPath withIntermediateDirectories:YES attributes:nil error:nil];
[fileManager createFileAtPath:[DocumentsPath stringByAppendingString:@"/image.png"] contents:data attributes:nil];
设置图片可以剪切,注意枚举的使用
UIImage* image = [info objectForKey:@"UIImagePickerControllerEditedImage"];
图片转化为NSData
NSData *data;
//判断用的是不是png格式的图片
if (UIImagePNGRepresentation(image) == nil)
{
data = UIImageJPEGRepresentation(image, 1.0);
}
else
{
data = UIImagePNGRepresentation(image);
}
18:
NSNumber *sex = nil;
if (sex==nil) {
NSLog(@"%ld",[sex integerValue]);
}