imageView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
imageView.contentMode = UIViewContentModeScaleAspectFit;
imageView.backgroundColor = [UIColorblackColor];
self.view = imageView;
imageView.image = [recipes.
recipeImage valueForKey: @ "recipeImage"];
}
- (void) {didReceiveMemoryWarning
[superdidReceiveMemoryWarning];
}
- (void) {viewDidUnload
}
- (void) {dealloc
[superdealloc];
[receitas release];
[liberação imageView];
}
end
Salve esta e abrir AddRecipeViewController.h e adicionar um photoButton UIButton nomeado e um método IBAction para quando o botão é clicado
interface AddRecipeViewController:.
UIViewController {
Receitas * receitas;
UITextField * textFieldOne;
UITextField * textFieldTwo;
UIButton * photoButton;
}
property (não-atômicas, conservem) Receitas * receitas;
property (nonatomic, reter) IBOutletUITextField * textFieldOne;
property (nonatomic, reter) IBOutletUITextField * textFieldTwo;
property (nonatomic, reter) IBOutletUIButton * photoButton;
- (IBAction) photoButtonPressed;
< p>end
Abra o arquivo .m e escrever:
#import "AddRecipeViewController.
h"
#import "Recipes.h"
#import "PhotoViewController.h"
implementation AddRecipeViewController
synthesize receitas, textFieldOne, textFieldTwo, photoButton;
- (void) viewDidLoad {
[superviewDidLoad];
self.title = @ "Adicionar Receita";
UIBarButtonItem * CancelButton = [[UIBarButtonItemalloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCanceltarget:selfaction:@selector(cancel)];
self.navigationItem.
leftBarButtonItem = CancelButton;
[liberação CancelButton];
UIBarButtonItem * SaveButton = [[UIBarButtonItemalloc] initWithTitle:@"Save"style:UIBarButtonItemStyleDonetarget:selfaction:@selector(save)];
self.navigationItem.rightBarButtonItem = SaveButton;
[liberação SaveButton];
[photoButtonsetImage: recipes.recipeThumbnailImage forState: UIControlStateNormal];
}
- (void) viewWillAppear: (BOOL) animado {
[superviewWillAppear: animação];
[photoButtonsetImage: recipes.
recipeThumbna