Note: I want to collect as many open-source components as possible,
not just publish my own ones. If you have a useful iOS class that does
not depend on anything, feel free to fork, add and send me a pull
request!
ATPagingView
ATPagingView is a wrapper around UIScrollView in (horizontal) paging
mode, with an API similar to UITableView.
Status: production-ready, used by at least one App Store app.
You provide the page views by implementing two delegate methods:
Here's another example. The following function is useful in background
image loading code:
// Returns an uncompressed (decoded) UIImage, optimized for drawing speed.
//
// This is a middle ground between [UIImage imageNamed:] and a plain
// [UIImage imageWithContentsOfFile:], as follows:
//
// * [UIImage imageWithContentsOfFile:] loads image data from disk and
// decodes it each time you display the image.
//
// If you are using CATiledLayer to display a large image (and you should,
// since UIImageView is not recommended for images bigger than ~1024x1024),
// the whole JPEG will decoded for EACH tile you display.
//
// * [UIImage imageNamed:@"xxx"] only ever decodes the image once, just as you
// wanted. However it also caches the image and seems to sometimes (always?)
// not release the data even after you release your UIImage.
//
// An app that loads several large images via 'imageNamed' will thus crash
// quite soon with unfamous "error 0".
//
// Another undesired quality of 'imageNamed' is that the image is loaded and
// decoded when it is displayed for the first time, which means you can't
// really do the decoding in a background thread.
//
// * DecompressUIImage([UIImage imageWithContentsOfFile:@"xx.jpg"]) is the
// sweet spot between the two — it returns a fully decoded image which can
// be displayed quickly, and memory management is entirely up to you.
//
UIImage *DecompressUIImage(UIImage *image) {
ATByteImage *byteImage = [[[ATByteImage alloc] initWithImage:image] autorelease];
return [byteImage extractImage];
}
请发表评论