Skip to content

Commit

Permalink
14 prerequisites for modal display for new entry
Browse files Browse the repository at this point in the history
  • Loading branch information
gmarik committed Oct 13, 2011
1 parent 55198e6 commit 6bef394
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 3 deletions.
Expand Up @@ -28,6 +28,9 @@
@property (strong,nonatomic) Posession *posession;


// Designated initializer
-(id)initForNewItem:(BOOL)isNew;

// Picture
@property (strong, nonatomic) IBOutlet UIImageView *imageView;
- (IBAction)takePicture:(id)sender;
Expand Down
Expand Up @@ -18,6 +18,41 @@ @implementation ItemDetailsViewController
@synthesize imageView;


#pragma mark - designaed initializers

-(id)initForNewItem:(BOOL)isNew {
self = [super initWithNibName:nil bundle:nil];
if (!self) return self;

if (isNew) {
UIBarButtonItem *doneItem = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemDone
target:self
action:@selector(save:)];

UIBarButtonItem *cancelItem = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemCancel
target:self
action:@selector(cancel:)];

self.navigationItem.rightBarButtonItem = doneItem;
self.navigationItem.leftBarButtonItem = cancelItem;


}

return self;
}

-(id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
@throw [NSException exceptionWithName:@"Wrong initializer"
reason:@"Use initForNewItem:"
userInfo:nil];
return nil;
}

#pragma mark - dealloc

-(void)dealloc {
// [setNameField relese];
// [setSerialField release];
Expand All @@ -26,7 +61,7 @@ -(void)dealloc {
// [super dealloc];
}

#pragma mark - View callbacks
#pragma mark - View callbacks/delegate methods

-(void)viewWillAppear:(BOOL)animated
{
Expand Down
Expand Up @@ -68,8 +68,11 @@ -(IBAction)addNewPosession:(id)sender {

//UINavigationController
-(void) tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
ItemDetailsViewController *dc = [[ItemDetailsViewController alloc] init];
didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

ItemDetailsViewController *dc =
[[ItemDetailsViewController alloc] initForNewItem:NO];

NSArray *all = [[PosessionStore defaultStore] posessions];
Posession *p = [all objectAtIndex:[indexPath row]];
Expand Down

0 comments on commit 6bef394

Please sign in to comment.