Thanks for watching, please pay more attention!For more interview articles and answers, please watch the interview collection!
1、 Reuse mechanism
1. How does IOS implement the cell reuse mechanism?
A1-A7Use the same
A1After the page is marked out, it is put into the reuse pool.
A7When you are about to show it, you will first view it in the reuse pool
cellIt can be reused. If there is one, it will be directly taken out for use. If there is none, a new one will be created
Xiaobian has prepared some advanced interview materials here,The latest interview big factory often asks an interview answer。 I hope I can really help you improve your technology!
2. How to implement reuse mechanism manually?
ViewReusePoolUse of classes
2、 Data source synchronization problem
- When the data source is
Main threadThere are
deleteOperation, at the same time
Child threadThere’s another one on the
Load moreWhen the data is manipulated, the
Data source synchronization problem。
1. Data source synchronization solution
a. Concurrent access, data copy
Main threadThe deleted data is still included in the data.
Main threadWhen deleting, record the operation. Later in
Child threadWhen data is synchronized, the deletion operation is synchronized.
b. Serial access
Child threadData synchronization and
Main threadAll delete operations are put into one
Serial queueExecute in.
The deletion action may be delayed.
Event delivery & view response
1、 Uiview and calayer
1. What is the relationship and difference between uiview and calayer?
layerPoint to a
CALayerEncapsulation of an attribute with the same name.
UIViewThe display part is composed of
backing storeIt’s actually a
UIViewProvide them with content, handle touch and other events, and participate in the response chain.
CALayerResponsible for displaying content
2. Why is uiview responsible for touching events and calayer responsible for displaying them?
- Design patterns,
2、 Event delivery and view response chain
1. When you click View C2, how does the system find the response view?
a. Process of event delivery
- When the user clicks the screen, the event is displayed
UIApplicationAccept and pass on to
pointInsideDetermine whether the event is in the view.
- if it is
false, return to the view and the event delivery process ends.
- if it is
Flashback traversalOf this view
Subview, and call
- Find the end
Subview, and return in turn, and the event transfer process ends.
hitTestSystem internal implementation
- Called in the current view subview
hitTestFunction, you need to convert the current coordinates to
2. How to make only the circular area of the square picture accept the event response?
- Override view
pointInsideFunction to make the click area return within a circular range
true, otherwise return