Thursday, June 10, 2010
iPhone dev Stupidity 130: antialiasing on a rotated view
Wednesday, June 09, 2010
iPhone dev Stupidity 129: -all_load -ObjC linker flag in Xcode
From Apple Q&A
Q: Why do I get a runtime exception of "selector not recognized" when linking against an Objective-C static library that contains categories?
A: The "selector not recognized" runtime exception occurs due to an issue between the implementation of standard UNIX static libraries, the linker and the dynamic nature of Objective-C. Objective-C does not define linker symbols for each function (or method, in Objective-C) - instead, linker symbols are only generated for each class. If you extend a pre-existing class with categories, the linker does not know to associate the object code of the core class implementation and the category implementation. This prevents objects created in the resulting application from responding to a selector that is defined in the category.
To resolve this issue, the target linking against the static library must pass the -ObjC option to the linker. This flag causes the linker to load every object file in the library that defines an Objective-C class or category. While this option will typically result in a larger executable (due to additional object code loaded into the application), it will allow the successful creation of effective Objective-C static libraries that contain categories on existing classes. Follow these steps to pass -ObjC to the linker:
In Xcode, double-click the target's name under "Targets" in the Project window.
Choose the Build pane from the ensuing Info window.
Scroll down to the Other Linker Flags build setting under the Linking collection and set its value to -ObjC.
IMPORTANT: For 64-bit and iPhone OS applications, there is a linker bug that prevents -ObjC from loading objects files from static libraries that contain only categories and no classes. The workaround is to use the -all_load or -force_load flags.
-all_load forces the linker to load all object files from every archive it sees, even those without Objective-C code. -force_load is available in Xcode 3.2 and later. It allows finer grain control of archive loading. Each -force_load option must be followed by a path to an archive, and every object file in that archive will be loaded.
iPhone dev Stupidity 128: Photo orientation issue in Three20’s TT
iPhone dev Stupidity 127: How Three20 works
1. Create TTThumbesViewController via URL: "tt:\\phototest2"
2. When is the TTURLMap setuped?
3. And mapped to class
[map from:@"*" toViewController:[TTWebController class]];
[map from:@"tt://catalog" toViewController:[CatalogController class]];
[map from:@"tt://photoTest1" toViewController:[PhotoTest1Controller class]];
[map from:@"tt://photoTest2" toViewController:[PhotoTest2Controller class]];
4. How TTThumbsView get created?
5. URL protocol
6. A Tutorial on How to create a photo browser using Three20
iPhone dev Stupidity 126: private folder for images
//I do this in the didFinishPickingImage:(UIImage *)img method
NSData* imageData = UIImageJPEGRepresentation(img, 1.0);
//save to the default 100Apple(Camera Roll) folder.
[imageData writeToFile:@"/private/var/mobile/Media/DCIM/100APPLE/customImageFilename.jpg" atomically:NO];
The photos there are all named in IMG_####.JPG format.
NSArray *directoryContent = [[NSFileManager defaultManager] directoryContentsAtPath:@"/private/var/mobile/Media/DCIM/100APPLE/.MISC"];
for(NSString * dir in directoryContent){
NSLog(dir);
}
iPhone dev Stupidity 125: lack of EXIF with the iPhone API
iPhone dev Stupidity 124: Rotating view around arbitrary point th
iPhone dev Stupidity 123: How to launch iPhone Camera on viewDidL
You should do it in viewWillAppear:, or viewDidAppear: if the first doesn't work. trying to do it in viewDidLoad won't work because that is called after the view is first created, and the view isn't a subview of anything else at that point.
UIImageView animationImages
imageView.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"cameraScreenOverlay1.png"],
[UIImage imageNamed:@"cameraScreenOverlay2.png"],
[UIImage imageNamed:@"cameraScreenOverlay3.png"],
[UIImage imageNamed:@"cameraScreenOverlay4.png"],
[UIImage imageNamed:@"cameraScreenOverlay4.png"],
[UIImage imageNamed:@"cameraScreenOverlay4.png"],
[UIImage imageNamed:@"cameraScreenOverlay3.png"],
[UIImage imageNamed:@"cameraScreenOverlay2.png"],
[UIImage imageNamed:@"cameraScreenOverlay1.png"],
nil];
imageView.animationDuration = 1.0;
imageView.animationRepeatCount = 0;
[imageView startAnimating];
doesn't work when imageView is used as an overlay view above camera.
iPhone dev Stupidity 122: Customize bars, buttons, status bar
4. Hiding status bar via .plist