UIImage Two types of initialization differences
The first type of initialization: UIImage *image = [UIImage imagenamed:@ "xxx"]; Note (This method loads the picture if the suffix name is png, you can not write the suffix name, according to the screen resolution to match the picture yourself)
The second type of initialization:
NSString *path = [[NSBundle mainbundle] pathforresource:@ "Xxx.png" oftype:nil];
UIImage *image = [[UIImage alloc] initwithcontentsoffile:path]; Note (This method must write the suffix name)
Difference: The first method loads the picture and then puts the picture in the cache, and the next time the image is loaded, it can be read directly from the cache. Advantages: Convenient and quick, only the first time when loading a little slow, then will soon. Cons: Waste memory when the image is only loaded once in the project (note that this memory will be released only when the project is closed)
The second way to load a picture is to read the picture according to the path each time, the second method is recommended when the picture in the project only needs to be loaded once.
It's nothing to do today. Encapsulates an ad carousel control, the call is very simple, the external call of the time 1. If it's a local image, you just need to send an array of image names.
2. If it is a network image only need to pass a URL array is good
3 lines of code are done. And it can be automatically carousel, every second of the carousel. The finger swipe does not clash with the timer. Attached address: Https://github.com/guhaibo312/HBScrollView
UIImage two different types of initialization ad carousel encapsulation