tableView reloadData 程序延迟到reloadData结束在操作。
1. 通过layoutIfNeeded方法,强制重绘并等待完成。
[self.tableView reloadData];
[self.tableView layoutIfNeeded];
//刷新完成,执行后续需要执行的代码
2.reloadData方法会在主线程执行,通过GCD,使后续操作排队在reloadData后面执行。
[self.tableView reloadData];
dispatch_async(dispatch_get_main_queue(), ^{
//刷新完成,执行后续代码
});
事件冲突
#import "DKTouchTableView.h"
#import "DKSuspendMapView.h"
@implementation DKTouchTableView
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
CGPoint p = [gestureRecognizer locationInView:self.suspendMap.mapView];
BOOL pointInMapView = [self.suspendMap.mapView pointInside:p withEvent:nil];
self.scrollEnabled = !pointInMapView;
return YES;
}
手势共存
[singleTapGestureRecognizer requireGestureRecognizerToFail:doubleTapGestureRecognizer];
事件穿透
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event {
return [super hitTest:point withEvent:event];
}
runtime强制执行
SEL editSelector = self.editButtonItem.action;
IMP editImp = [self methodForSelector:editSelector];
void (*editFunc)(id, SEL) = (void *)editImp;
editFunc(self, editSelector);
多个Button点击
[UIButton appearance].isExclusiveTouch = YES;
基类
self.navigationController.navigationBar.translucent = NO;
self.automaticallyAdjustsScrollViewInsets = NO;
cell进入编辑模式
-(void)didTransitionToState:(UITableViewCellStateMask)state
通过Clang将mian.m文件编译为C++
clang -rewrite-objc main.m
还是字符串靠谱
使用Xib自定义view的深坑!!!!!
绝对不可以 LBWealthCenterViewController 里面 有一个 LBWealthCenterView的自定义xibView
子视图不响应父视图的手势识别器
/** 让子视图不响应父视图的手势识别器 */
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{
if (touch.view == self) {
return YES;
}
if ([touch.view isDescendantOfView:self]) {
return NO;
}
return YES;
}
忽略编译器警告
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunguarded-availability"
#pragma clang diagnostic pop
build setting => other waring flags