Silver Challenge


I added a button to the toolbar, which for some reason sits next to camera button and wont move to far right the way I wanted, not sure what I am missing.

Here is the correspoding action code in BNRDetailViewController:

[code]- (IBAction)deleteImage:(id)sender {
[[BNRImageStore sharedStore] deleteImageForKey:self.item.itemKey];
self.imageView.image = nil;


Does this satisfy the challenge?


That’s how a toolbar works.
If you want to move it you need to add a flexible space, I think! (flexible space for bar button item)
Haven’t done so myself, but I know that that should do the trick.


Yep, that is how the UIToolbar works. As the above posted said, you can add a “flexible space” between the two items to solve the problem you are trying to solve. In code, that is a UIBarButtonSystemItemFlexibleSpace. You can do this in the XIB file by adding a “Flexible Space Bar Button Item” to the toolbar in between the other two items.

To answer your question though, yes, that looks like it should solve the challenge.


When i am in detailview, and push camerabutton, it takes some time to load and recieve a memory warning. Is it better to initialize the UIImagePicker when the detailview is loading or just initialize it when you will take a picture as it is now?


This is exactly what I did for the Silver challenge. Nice and easy.


You definitely want to only load a UIImagePicker when you need to take a picture. If you initialize it in viewWillAppear, for example, it will be hanging around for as long as the view exists, whether it gets used or not. Even if all you’re trying to do is make a minor edit to one of the text fields, the UIImagePickerController will be initialized, which could affect the perceived performance of your app, to a greater or lesser extent depending on the age of the device. Given that there’s no guarantee the user will be adding or editing an image when they tap to see the details of an item, it’s more acceptable to take a performance hit when they definitely need to use the camera (i.e. they tap on the camera icon) than it is to have them experience a performance hit every single time they view the details of an item.


I showed / hid the ‘Delete Image’ button accordin to whether or not there is an image to delete. A smattering of

[self.deleteImageButton setHidden:YES]; and [self.deleteImageButton setHidden:NO]; in BNRDetailViewController.m.