iOS 易被忽视的细节

1 点击子view 会出发父view的此方法

  • (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event

解决方法,在子view中实现此方法可阻断父视图响应此方法

Xcode调试技巧

3.取消延迟方法执行

(void)performSelector:(SEL)aSelector withObject:(nullable id)anArgument afterDelay:(NSTimeInterval)delay inModes:(NSArray *)modes;
(void)performSelector:(SEL)aSelector withObject:(nullable id)anArgument afterDelay:(NSTimeInterval)delay
performSelector N秒钟之后 执行方法

(void)cancelPreviousPerformRequestsWithTarget:(id)aTarget selector:(SEL)aSelector object:(nullable id)anArgument;
(void)cancelPreviousPerformRequestsWithTarget:(id)aTarget

cancelPreviousPerformRequestsWithTarget:取消performSelector方法注册过的方法,就是说当上面这个方法正在运行,比如希望5秒钟之后执行某一个方法,但是没到5秒钟的情况下取消performSelector,就是用cancelPreviousPerformRequestsWithTarget方法来实现的

你可能感兴趣的:(iOS 易被忽视的细节)