1, as far as possible without dynamic height
2. If it is dynamic height, calculate the height to be displayed in advance and use certain rules to bind the corresponding object to cache for the next use
3, do not assign the UI elements in the Layoutsubviews method, set the style, etc., layoutsubviews This method may be called again because of a change in the content,
So there will be many calculations or repainting.
4, add Subview in TableView Cell with Content.view.addSubView method, if the direct addsubview may call Layoutsubviews This method more than once.
5, reduce the main thread offscreenrendering operation
A, make reasonable use of the Shouldrasterize property of layer (this property is to cache the static content of the page, if the page element is dynamic, the result of the cache does not have much effect on the cost of resources)
b, using fillet picture instead of setting layer's Cornerradius, setting layer's Cornerradius is also a kind of offscreen rendering operation
C, set the shadow, use [Myview.layer setshadowpath:[[uibezierpath bezierPathWithRect:myView.bounds] cgpath]; than [Myview.layer SETSHADOWOPACITY:0.5] is highly efficient
D, reduce the mask of layer
E, the view is set as opaque as possible to reduce the blending between views
F, anti-aliasing layer.edgeantialiasingmask, layer.allowsedgeantialiasing
6. Shell Cell & Realcell: There is no need to return Realcell when scrolling fast, just return a shell cell and return to the Realcell you want to display when the TableView scrolling rate drops to a certain level.
-(void) Scrollviewdidscroll: (Uiscrollview *) ScrollView
{Cgpoint velocity = [Tableview.pangesturerecognizer velocityInView:self.view]; self.velocity = velocity;
}
-(uitableviewcell*) TableView: (uitableview*) TableView Cellforrowatindexpath: (nsindexpath*) Indexpath {if (Fabs ( SELF.VELOCITY.Y) > 2000)
{
return shell cell}else{//return real Cell
} }
6, for some complex views in the DrawRect: method to directly draw the view of the effect of a container to add label,imageview more efficient (memory overhead, spend more time)
7, do not work in the main thread of those not displayed in the page UI data, such as TableView scrolling when the page to judge, showing the first in the process of scrolling with other threads will be displayed in the data processing, rather than in the display of the processing
8, display the size of the picture as far as possible and imageview the same size, reduce the picture in order to due to the size of the process caused by inconsistency.
9. Minimize the depth of UI layout and use flat layout to reduce blending between elements
10, reasonable choice of database cache: Simple data cache do not use relational database
11. Reduce duplicate processing of same data
12. Reuse objects with large overhead (e.g. nspredicate,nsdateformatter,nsregressexpression)
13, use: AutoLayout use to see the view, Subview less view
With AutoLayout compare cost, subview more view with AutoLayout cost will be larger
(Setframe is the fastest, followed by elements that depend on their own layout, followed by the parent view)
UIWebView
1. Try to reuse objects in WebView
2. Reduce the number of WebView instance objects in the project (with a WebView object and then load the corresponding displayed content each time)
3, priority to use Loadhtmlstring:baseurl: Then is loadrequest: to load a Web page
The implementation of the WebView:didFailLoadWithError:ofthedelegate method enables WebView to turn off the tracking of an error in a timely manner, while also allowing for a better experience with the errors that occur in WebView.
The speed at which the app opens
TIP1: Reduce pre-add-ons at app startup
A, reducing the number of class methods
class method needs to be loaded when the app starts
B, reduce the number of Xib,stroyboard
C, reduce non-essential network load (as light as possible) when booting up
Ios8 uses Webkit,webkit to have a better experience than UIWebView.
Memory optimization:
1, reduce the type conversion, try to use a defined type to match
such as – (int) GetValue; The int a=getvalue consumes less memory than long a=getvalue,
Enumeration type is assigned as far as possible if the variable definition is an integer that accesses the enumeration value
2. The longer the object exists in memory, the more likely it is to cause memory leaks, global variables, and a single case
Power consumption:
Timer
Positioning
Io Read/write
Video playback
Summary: Multi-cache, less computation, less conversion.
iOS Performance optimization strategy