imageView.contentMode = UIViewContentModeScaleAspectFit;
imageView.backgroundColor = [UIColorblackColor];
self.view = bildeVis;
imageView.image = [recipes.recipeImage valueForKey: @ "recipeImage"];
}
- (void) didReceiveMemoryWarning {
[superdidReceiveMemoryWarning];
}
- (void) viewDidUnload {
}
- (void) dealloc {
[superdealloc];
[oppskrifter utgivelsen];
[bildeVis utgivelsen];
}
end
Lagre denne og åpne opp AddRecipeViewController.
h og legge en UIButton heter photoButton og en IBAction metode for når knappen klikkes
interface AddRecipeViewController. UIViewController {
Oppskrifter * oppskrifter;
UITextField * textFieldOne;
UITextField * textFieldTwo;
UIButton * photoButton;
}
property (nonatomic, beholder) Oppskrifter * oppskrifter;
property (nonatomic, beholde) IBOutletUITextField * textFieldOne;
property (nonatomic, beholde) IBOutletUITextField * textFieldTwo;
property (nonatomic, beholde) IBOutletUIButton * photoButton;
- (IBAction) photoButtonPressed;
< p>end
Åpne .
m filen og skrive:
#import "AddRecipeViewController.h"
#import "Recipes.h"
#import "PhotoViewController.h"
implementation AddRecipeViewController
synthesize oppskrifter, textFieldOne, textFieldTwo, photoButton;
- (void) viewDidLoad {
[superviewDidLoad];
self.title = @ "Legg oppskrift";
UIBarButtonItem * Avbryt-= [[UIBarButtonItemalloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCanceltarget:selfaction:@selector(cancel)];
self.navigationItem.
leftBarButtonItem = Avbryt-;
[Avbryt-utgivelsen];
UIBarButtonItem * saveButton = [[UIBarButtonItemalloc] initWithTitle:@"Save"style:UIBarButtonItemStyleDonetarget:selfaction:@selector(save)];
self.navigationItem.rightBarButtonItem = SaveButton;
[saveButton utgivelsen];
[photoButtonsetImage: recipes.recipeThumbnailImage forState: UIControlStateNormal];
}
- (void) viewWillAppear: (BOOL) animert {
[superviewWillAppear: animerte];
[photoButtonsetImage: recipes.
recipeThumbnailImage forState: UIControlStateNormal];
}
- (void ) avlyse {
[recipes.managedObjectContextdeleteObject: oppskrifter];
NET - C # - Bruke UserControls Mail …