1.self.edgesForExtendedLayout = UIRectEdgeBottom ; //https://www.cnblogs.com/SoulKai/p/5811296.html
2.model中id属性解决方法:
在controller中添加 :
[OrderModel mj_setupReplacedKeyFromPropertyName:^NSDictionary *{
return @{@"ID":@"id"};
}];
3.跳转tabbar控制页面: self.tabBarController.selectedIndex = 1;
4.tableview section悬停问题解决: UITableViewStyleGrouped
self.tableView.estimatedRowHeight = 0;
self.tableView.estimatedSectionHeaderHeight = 0;
self.tableView.estimatedSectionFooterHeight = 0;
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;隐藏分割线
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
return CGFLOAT_MIN;
}
5.打电话弹窗:
dispatch_async(dispatch_get_main_queue(), ^{
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"拨打客服" message:@"客服的服务时间为\n 9:00 - 20:00" preferredStyle:(UIAlertControllerStyleAlert)];
UIAlertAction *confirm = [UIAlertAction actionWithTitle:@"拨号" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {
NSString *callPhone = [NSString stringWithFormat:@"telprompt://%@", self.phone];
NSComparisonResult compare = [[UIDevice currentDevice].systemVersion compare:@"10.0"];
dispatch_async(dispatch_get_main_queue(), ^{
if (compare == NSOrderedDescending || compare == NSOrderedSame) {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:callPhone]];
}else{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:callPhone]];
}
});
}];
UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"取消" style:(UIAlertActionStyleCancel) handler:nil];
[alert addAction:confirm];
[alert addAction:cancel];
[self.viewController presentViewController:alert animated:YES completion:nil];
});
6.时间戳转换:
- (NSString *)getTimeFromTimesTamp:(NSString *)timeStr
{
double time = [timeStr doubleValue];
NSDate *myDate = [NSDate dateWithTimeIntervalSince1970:time];
NSDateFormatter *formatter = [NSDateFormatter new];
[formatter setDateFormat:@"YYYY-MM-dd HH:mm:ss"];
//将时间转换为字符串
NSString *timeS = [formatter stringFromDate:myDate];
return timeS;
}
7.imageview添加手势:
self.headerImg.userInteractionEnabled = YES;
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(clickRegistrationAgreementBtn)];
[self.headerImg addGestureRecognizer:tapGesture];
8.imageview添加边框: self.headerImg.layer.borderColor = [YJUIColorRGB(67, 64, 63) CGColor];
self.headerImg.layer.borderWidth = 5.0f;
圆角: self.headerImg.layer.masksToBounds = YES;
self.headerImg.layer.cornerRadius = 30;
9.label文字设置:
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"确认收货并转卖 可得%@现金返利",model.fee_rate]];
[attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:119.0f/255.0f green:119.0f/255.0f blue:119.0f/255.0f alpha:1.0f] range:NSMakeRange(0, 10)];
[attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:243.0f/255.0f green:194.0f/255.0f blue:108.0f/255.0f alpha:1.0f] range:NSMakeRange(10, 3)];
[attributedString addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:119.0f/255.0f green:119.0f/255.0f blue:119.0f/255.0f alpha:1.0f] range:NSMakeRange(13, 4)];
_grayLabel.attributedText = attributedString;
10.label添加长按手势复制功能:
_grayLabel.userInteractionEnabled = YES;
UILongPressGestureRecognizer * longPressGr = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPre:)];
[_grayLabel addGestureRecognizer:longPressGr];
- (BOOL)canBecomeFirstResponder{
return YES;
}
// 可以控制响应的方法
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender{
return (action == @selector(copy:));
}
// 处理长按事件
- (void)longPre:(UILongPressGestureRecognizer *)recognizer{
[self becomeFirstResponder]; // 用于UIMenuController显示,缺一不可
//UIMenuController:可以通过这个类实现点击内容,或者长按内容时展示出复制等选择的项,每个选项都是一个UIMenuItem对象
UIMenuItem *copyLink = [[UIMenuItem alloc] initWithTitle:@"复制" action:@selector(copy:)];
[[UIMenuController sharedMenuController] setMenuItems:[NSArray arrayWithObjects:copyLink, nil]];
[[UIMenuController sharedMenuController] setTargetRect:self.grayLabel.frame inView:self.grayLabel.superview];
[[UIMenuController sharedMenuController] setMenuVisible:YES animated:YES];
}
-(void)copy:(id)sender{
UIPasteboard *pboard = [UIPasteboard generalPasteboard];
pboard.string = self.grayLabel.text;
[LEPProgressHUD showSuccess:@"复制成功"];
}
11.置顶:
-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[self.mTableView setContentOffset:CGPointMake(0,0) animated:NO];
}
12.代码混淆
1.bundle id
2.项目名称
3.类名
4.本地文件夹名字
5.项目目录名字
6.文件顶部注释
7.加垃圾属性
8.垃圾属性的调用
9.方法增加稍微长点前缀
13.单元测试
14.新添加的苹果账号需要重新从钥匙串申请证书、申请开发者证书
15.xcode搜索区分大小写
16.coding使用
https://www.cnblogs.com/tangyikejun/p/4147623.html
17.label设置不同颜色字体大小
UILabel *agreementLabel =[[UILabel alloc]init];
agreementLabel.textAlignment = NSTextAlignmentCenter;
agreementLabel.font =[UIFont systemFontOfSize:11];
agreementLabel.userInteractionEnabled = YES;
agreementLabel.textColor = YJUIColorHex(@"#acacac");
NSMutableAttributedString *ms = [[NSMutableAttributedString alloc] initWithString:@"您已同意" attributes:@{NSForegroundColorAttributeName:YJUIColorRGB(170, 170, 170),NSFontAttributeName:[UIFont systemFontOfSize:11]}];
[ms appendAttributedString:[[NSAttributedString alloc] initWithString:@"《淘福利用户协议》" attributes:@{NSForegroundColorAttributeName:YJUIColorRGB(67, 64, 63),NSFontAttributeName:[UIFont systemFontOfSize:11]}]];
[agreementLabel setAttributedText:ms];
[self.headerImg addSubview:agreementLabel];
agreementLabel.sd_layout.centerXEqualToView(self.headerImg).bottomSpaceToView(self.headerImg, 25).widthIs(200).heightIs(17);
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(agreementBtn)];
[agreementLabel addGestureRecognizer:tapGesture];
18.系统cell
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
cell.textLabel.text = @"出发点";
return cell;
19.model关键字 处理
[ProductModel mj_setupReplacedKeyFromPropertyName:^NSDictionary *{
return @{@"ID":@"id"};
}];
20.随机颜色
cells.backgroundColor = [UIColor colorWithRed:((10 * indexPath.row) / 255.0) green:((20 * indexPath.row)/255.0) blue:((30 * indexPath.row)/255.0) alpha:1.0f];
22更改项目名 https://www.cnblogs.com/liangyi-cn/p/8657474.html
23 返回指定页
self.tabBarController.selectedIndex = 0;
[self.navigationController popToRootViewControllerAnimated:NO];
或
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
FLTabBarViewController *tabViewController = (FLTabBarViewController *) appDelegate.window.rootViewController;
[tabViewController setSelectedIndex:0];
24 键盘上的Done也会变成响应的中文
在project->info->Localizations添加chinese选项
25 按钮自适应
button.titleLabel.baselineAdjustment = UIBaselineAdjustmentAlignCenters;//垂直居中基准线
button.titleLabel.adjustsFontSizeToFitWidth = YES;
待续。。