带点的数字键盘
场景:输入金额时用到
textFiledMoney.keyboardType = UIKeyboardTypeDecimalPad;
(0,0)点开始布局
if (@available(iOS 11.0, *)) {
_tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}else{
self.automaticallyAdjustsScrollViewInsets =NO;
}
tableview collectionview 刷新指定组和cell
//一个section刷新
NSIndexSet *indexSet=[[NSIndexSet alloc]initWithIndex:1]; //你需要更新的组数
[tableview reloadSections:indexSet withRowAnimation:UITableViewRowAnimationAutomatic];
//一个cell刷新.
//你需要更新的组数中的cell
NSIndexPath *indexPath=[NSIndexPath indexPathForRow:3 inSection:0];
[tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath,nil] withRowAnimation:UITableViewRowAnimationNone];
collection 相同
关于tableview 刷新cell
1.如果需要改变cell 的内容高度,则用[tableview reloadData]
2.如果只是改变内容,不改变cell高度,可以刷新单个cell
iOS 界面跳转卡住 但是不崩溃问题
!!!
- 原因是在rootviewcontroller 触发了右滑手势
- 此种情况出现在自定义导航控制器返回按钮,防止滑动返回失效
自定义返回按钮代码
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
if (self.viewControllers.count > 0) {
TSLog(self.viewControllers.count);
///第二层viewcontroller 隐藏tabbar
viewController.hidesBottomBarWhenPushed=YES;
UIButton * btn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
[btn setImage:[UIImage imageNamed:@"navbar_icon_back"] forState:UIControlStateNormal];
btn.title = @"返回";
btn.titleFont = 16;
viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:btn];
[btn addTarget:self action:@selector(returnCustom) forControlEvents:UIControlEventTouchUpInside];
// 如果自定义返回按钮后, 滑动返回可能失效, 需要添加下面的代码
__weak typeof(viewController)Weakself = viewController;
self.interactivePopGestureRecognizer.enabled = [self.viewControllers count] > 1 ;
self.interactivePopGestureRecognizer.delegate = (id)Weakself;
}
[super pushViewController:viewController animated:animated];
}
其中重要的代码
//[self.viewControllers count] 控制是否响应滑动手势
self.interactivePopGestureRecognizer.enabled = [self.viewControllers count] > 1 ;
项目中模拟数据用到 (范围随机数)-- (N~N)
-(int)getRandomNumber:(int)from to:(int)to
{
return (int)(from + (arc4random() % (to - from + 1)));
}
获取某个控件相对屏幕的位置
UIWindow * window=[[[UIApplication sharedApplication] delegate] window];
CGRect startRact = [Lable convertRect:Lable.bounds toView:window];
cell中使用 RAC 重复调用
[[[_joinRoomBtn rac_signalForControlEvents:UIControlEventTouchUpInside]takeUntil:cell.rac_prepareForReuseSignal]subscribeNext:^(__kindof UIControl * _Nullable x) {
}];
网友评论