前言:最近一直忙于项目,总结都直接顺手放在了笔记里,文章疏于打理迟迟没有更新,在这里跟各位说句对不起。本来打算上一篇记录到400条的时候再新开一篇,可是更新的时候一直出现崩溃的情况,索性就直接转到这里了。git
1.关于在NSobject类中没法声明UImageView *等参数
Framwork要加入UIKit框架,UIImage才能使用json
2.打包时选择了表述文件后
只会显示对应的一个证书,只要有多个证书就重启一遍xcodexcode
3.白色字体由于背景图片而看不清如何处理
在背景图片上蒙一层半透明的UIImageView便可框架
4.bounce能够控制scrollview的反弹效果
为BOOL型变量,可设置iphone
5.在响应事件内切换tabBar编辑器
self.tabBarController.selectedIndex = 1;
6.git 快速找到clone地址ide
git remote -v
7.打包时出现 3D0CC99EBF87D6479CF799461890E07C85685769: no identity found Command /usr/bin/codesign failed with exit code 1 错误
相似错误是证书不对,没运行证书测试
8.iOS报错[__NSCFNumber length]: unrecognized selector sent to instance
出现这种报错很大的缘由是由于类型给错了,或许你这个数据是从json上解析后获得的,可是须要看一下这个数据是NSString仍是NSNumber类型,若是是NSNumber类型的话,你又直接使用NSString类型的变量去接收他,那么确定会报这样的错误,因此必定要注意数据的类型字体
9.设置键盘右下角按钮的类型,如:完成ui
self.searchTextField.returnKeyType = UIReturnKeyDone;
10.当代码建立tableIView后注册的cell为nil时的缘由
1.该tableView被隐藏,查看hidden属性是否为YES
2.是否同一界面存在多个tableView,是的话在须要判断的地方以下处理:
tableView = tableViewA;
tableView = tableViewB;
11.UIButton的UIControlEventTouchUpInside无响应问题
查看其父控件是否继承了某些类,或直接从父控件中转移到平级便可解决
12.在实现录音长按等效果时,UIButton不须要加长按手势
使用UIControlEventTouchDown(点下去) 这个按下去的操做来判断
监听抬手动做时用UIControlEventTouchUpInside(点下去弹起来)来判断便可
13.长按手势的开始和结束
-(void)longPress:(UILongPressGestureRecognizer *)gestureRecognizer { //长按开始 if ([gestureRecognizer state] == UIGestureRecognizerStateBegan) { [self.voiceSignView.voiceButton setBackgroundImage:[UIImage imageNamed:@"bf1"] forState:UIControlStateNormal]; self.voiceSignView.promptLabel.text = @"松手结束"; self.voiceSignView.cancelButton.hidden = YES; self.voiceSignView.saveButton.hidden = YES; //长按结束 } else if ([gestureRecognizer state] == UIGestureRecognizerStateEnded) { } }
14.tableView返回顶部,一般使用在下拉刷新时
[self.tableView setContentOffset:CGPointMake(0, 0) animated:YES];
15.presentViewController过去以后navigation不见了或者push操做没法响应
是由于presentViewController 须要使用的是navigationController的sb ID,换成navigationController的sb ID就能够了。
16.真机测试出现Your build settings specify a provisioning profile with
1.找到项目中的**.xcodeproj文件,点击右键,show package contents(打开包内容)。
2.打开后找到project.pbxproj文件,用文本编辑器打开。其实就是右键,点击open就行了。
3.打开这个文件后,按command+F,在这个文件中查找“PROVISIONING_PROFILE",找到和这个“
PROVISIONING_PROFILE = "487F3EAC-05FB-4A2A-9EA0-31F1F35760EB"; "PROVISIONING_PROFILE[sdk=iphoneos*]" = "487F3EAC-05FB-4A2A-9EA0-31F1F35760EB";”相似的都删除。
4.而后保存文件,从新打开项目。xcode会提示你从新下载安装provisioning profile文件。下载后安装上就能够。
17.更改segmentControl图片
UIImage * imageSel = [UIImage imageNamed:@"d_seg_sel"]; [self.segmentButton setBackgroundImage:[imageSel resizableImageWithCapInsets:UIEdgeInsetsMake(10, 10, 0, 10) resizingMode:UIImageResizingModeStretch] forState:UIControlStateSelected barMetrics:UIBarMetricsDefault]; UIImage * imageNor = [UIImage imageNamed:@"d_seg_nor"]; [self.segmentButton setBackgroundImage:[imageNor resizableImageWithCapInsets:UIEdgeInsetsMake(10, 10, 0, 10) resizingMode:UIImageResizingModeStretch] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
18.隐藏UIScrollView的滚动条(一样适用于父类继承自UIScrollView的控件,如UITableView,UICollectionView等)
scrollView.showsVerticalScrollIndicator = FALSE; scrollView.showsHorizontalScrollIndicator = FALSE;
19.关于segmentButton存在多个并排segment而展现不完的解决方法
1.将字体超过局限的segment的Width进行调整便可
2.使用UICollectionView进行假装
20.撤回登录界面
present对应dismiss
push对应pop
例:
若是登录是
UINavigationController * loginNavigationController = getViewController(@"login", @"Login"); [[[[UIApplication sharedApplication]keyWindow]rootViewController] presentViewController:loginNavigationController animated:YES completion:^{ XS_APP_DELEGATE.tabBarController = nil; }];
那么取消登录就是
[self.view endEditing:YES]; [[[[UIApplication sharedApplication]keyWindow]rootViewController] dismissViewControllerAnimated:YES completion:^{ }];
21.计算日期,昨日-今日-以及以后的几天日期
self.dataArray = [[NSMutableArray alloc] init]; NSDate * date = [NSDate date]; NSDateFormatter * dateFormatter = [[NSDateFormatter alloc] init]; [dateFormatter setDateFormat:@"MM.dd"]; NSDate * yesterday = [NSDate dateWithTimeInterval:-24 * 60 * 60 sinceDate:date]; NSString * yesterdayString = [dateFormatter stringFromDate:yesterday]; [self.dataArray addObject:yesterdayString]; [self.dataArray addObject:@"今日"]; [self.dataArray addObject:@"明日"]; NSDate * after; for (int i = 2; i < 6; i ++) { after = [NSDate dateWithTimeInterval:i * 24 * 60 * 60 sinceDate:date]; NSString * afterString = [dateFormatter stringFromDate:after]; [self.dataArray addObject:afterString]; }
22.设置UIButton的UIFont
cancelButton.titleLabel.font = [UIFont fontWithName:@"HelveticaNeue-Bold" size:14];
23.@property和@interface声明变量的区别
用@interface声明的属性,只能在这个父类中使用,是彻底私有的,用@property声明的属性外部是能够访问的,同时,用@property声明的对象系统会给予一个get和set的方法属性,这个是管理内存一个重要的方式 在oc里面,也能够说,用@property可使用self,能够进行重写的操做,而@interface不能够
24.返回到指定viewController
NSArray * vcArray = self.navigationController.viewControllers; for (UIViewController * vc in vcArray) { if ([vc isKindOfClass:[XSConfiderSettingTableViewController class]]) { [self.navigationController popToViewController:vc animated:YES]; } }
也能够:
[self.navigationController popToViewController:[vcArray objectAtIndex:index] animated:YES];
其中index能够根据实际状况而定,返回指定第几个viewController
25.若是判断不了arrray[n]是否存在,就判断array.count > n
26.自定义section的文字颜色背景等
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { UIView * sectionView = [[UIView alloc] init]; sectionView.backgroundColor = [UIColor colorWithRed:242/255.0 green:243/255.0 blue:248/255.0 alpha:1.0]; UILabel * titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(16, 0, 190, 30)]; [titleLabel setFont:[UIFont systemFontOfSize:14]]; titleLabel.textColor = kColor; titleLabel.text = @"选择开通的套餐服务"; [sectionView addSubview:titleLabel]; return sectionView; }
27.UISwitch的颜色样式无需自定义重写
直接在其ON Tint属性中设置就好了,固然还有Thumb Tint属性
28.画远离字体的UILabel边框的取巧方法
在内容的两侧加上空格便可撑开边框,如:
NSString * info = @"内容"; self.label = [NSString stringWithFormat:@" %@ ", info];
29.一个统一设置label边框的方法(当该类存在多个UILabel控件须要画上边框时)
//统一设置label边框 -(void)changeLabelBorder:(UILabel *)label borderColor:(UIColor *)color { label.layer.masksToBounds = YES; label.layer.cornerRadius = 7;//圆角 label.layer.borderColor = color.CGColor;//边框颜色 label.layer.borderWidth = 0.5;//边框宽度 label.textColor = color;//字体颜色 }
30.静态UITableView的cell箭头设置方法 在storyBoard中选中tableView选择Accessory ->Disclosure Indicator