From d40cafee461021e9a10e4698196e14720cb50c21 Mon Sep 17 00:00:00 2001 From: Eddie Ehlin Date: Sun, 20 Jan 2013 22:35:40 +0100 Subject: Fixed the UIScrollView so that it will show the content properly and beans tableview is expanded to show all beans (no scrolling). --- iBean/iBean.xcodeproj/project.pbxproj | 6 + .../UserInterfaceState.xcuserstate | Bin 36309 -> 36973 bytes iBean/iBean/BeanCollectionExtractionScrollView.h | 13 ++ iBean/iBean/BeanCollectionExtractionScrollView.m | 53 ++++++ .../iBean/BeanCollectionExtractionViewController.h | 3 + .../iBean/BeanCollectionExtractionViewController.m | 33 +++- iBean/iBean/iPhoneStoryboard.storyboard | 209 +++++++++++++-------- 7 files changed, 238 insertions(+), 79 deletions(-) create mode 100644 iBean/iBean/BeanCollectionExtractionScrollView.h create mode 100644 iBean/iBean/BeanCollectionExtractionScrollView.m diff --git a/iBean/iBean.xcodeproj/project.pbxproj b/iBean/iBean.xcodeproj/project.pbxproj index f809461..22eba16 100644 --- a/iBean/iBean.xcodeproj/project.pbxproj +++ b/iBean/iBean.xcodeproj/project.pbxproj @@ -35,6 +35,7 @@ 024F676D16A4A61D004A1201 /* InstantExtractionViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 024F676C16A4A61D004A1201 /* InstantExtractionViewController.m */; }; 02E557AE16A9C1E40080FBBA /* BeanCollectionExtractionViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 02E557AD16A9C1E40080FBBA /* BeanCollectionExtractionViewController.m */; }; 02E557B116A9CFB50080FBBA /* BeanCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 02E557B016A9CFB50080FBBA /* BeanCell.m */; }; + 02E557BA16AC85A20080FBBA /* BeanCollectionExtractionScrollView.m in Sources */ = {isa = PBXBuildFile; fileRef = 02E557B916AC85A20080FBBA /* BeanCollectionExtractionScrollView.m */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -86,6 +87,8 @@ 02E557AD16A9C1E40080FBBA /* BeanCollectionExtractionViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BeanCollectionExtractionViewController.m; sourceTree = ""; }; 02E557AF16A9CFB50080FBBA /* BeanCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BeanCell.h; sourceTree = ""; }; 02E557B016A9CFB50080FBBA /* BeanCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BeanCell.m; sourceTree = ""; }; + 02E557B816AC85A20080FBBA /* BeanCollectionExtractionScrollView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BeanCollectionExtractionScrollView.h; sourceTree = ""; }; + 02E557B916AC85A20080FBBA /* BeanCollectionExtractionScrollView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BeanCollectionExtractionScrollView.m; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -273,6 +276,8 @@ 02E557B016A9CFB50080FBBA /* BeanCell.m */, 02E557AC16A9C1E40080FBBA /* BeanCollectionExtractionViewController.h */, 02E557AD16A9C1E40080FBBA /* BeanCollectionExtractionViewController.m */, + 02E557B816AC85A20080FBBA /* BeanCollectionExtractionScrollView.h */, + 02E557B916AC85A20080FBBA /* BeanCollectionExtractionScrollView.m */, ); name = BeanCollectionExtraction; sourceTree = ""; @@ -362,6 +367,7 @@ 024F676D16A4A61D004A1201 /* InstantExtractionViewController.m in Sources */, 02E557AE16A9C1E40080FBBA /* BeanCollectionExtractionViewController.m in Sources */, 02E557B116A9CFB50080FBBA /* BeanCell.m in Sources */, + 02E557BA16AC85A20080FBBA /* BeanCollectionExtractionScrollView.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/iBean/iBean.xcodeproj/project.xcworkspace/xcuserdata/eddiex.xcuserdatad/UserInterfaceState.xcuserstate b/iBean/iBean.xcodeproj/project.xcworkspace/xcuserdata/eddiex.xcuserdatad/UserInterfaceState.xcuserstate index d93e807..863f4fe 100644 Binary files a/iBean/iBean.xcodeproj/project.xcworkspace/xcuserdata/eddiex.xcuserdatad/UserInterfaceState.xcuserstate and b/iBean/iBean.xcodeproj/project.xcworkspace/xcuserdata/eddiex.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/iBean/iBean/BeanCollectionExtractionScrollView.h b/iBean/iBean/BeanCollectionExtractionScrollView.h new file mode 100644 index 0000000..40ac170 --- /dev/null +++ b/iBean/iBean/BeanCollectionExtractionScrollView.h @@ -0,0 +1,13 @@ +// +// BeanCollectionExtractionScrollView.h +// iBean +// +// Created by Eddie Ehlin on 2013-01-20. +// Copyright (c) 2013 Eddie Ehlin. All rights reserved. +// + +#import + +@interface BeanCollectionExtractionScrollView : UIScrollView + +@end diff --git a/iBean/iBean/BeanCollectionExtractionScrollView.m b/iBean/iBean/BeanCollectionExtractionScrollView.m new file mode 100644 index 0000000..ea42000 --- /dev/null +++ b/iBean/iBean/BeanCollectionExtractionScrollView.m @@ -0,0 +1,53 @@ +// +// BeanCollectionExtractionScrollView.m +// iBean +// +// Created by Eddie Ehlin on 2013-01-20. +// Copyright (c) 2013 Eddie Ehlin. All rights reserved. +// + +#import "BeanCollectionExtractionScrollView.h" + +@implementation BeanCollectionExtractionScrollView + +- (id)initWithFrame:(CGRect)frame +{ + self = [super initWithFrame:frame]; + if (self) { + // Initialization code + } + return self; +} + +- (void) layoutSubviews +{ + [super layoutSubviews]; + + //Resize the UITableView containing all the beans + UITableView *bt = [self.subviews objectAtIndex:0]; + bt.frame = CGRectMake(bt.frame.origin.x, bt.frame.origin.y, bt.frame.size.width, [bt numberOfRowsInSection:0]*60+20); + + //Move down the note text view, so that it don't overlaps the table. + UITextView *note = [self.subviews objectAtIndex:1]; + note.frame = CGRectMake(note.frame.origin.x, (bt.frame.origin.y + bt.frame.size.height)+15, note.frame.size.width, note.frame.size.height); + + //Set the content size to the scroll view. + //Note: If the note is hidden, then we should not include it (the same goes for the padding between note and table) + [self setContentSize: CGSizeMake(self.contentSize.width, bt.frame.size.height + (note.isHidden ? -15 : note.frame.size.height))]; + + //http://developer.apple.com/library/ios/#documentation/WindowsViews/Conceptual/UIScrollView_pg/CreatingBasicScrollViews/CreatingBasicScrollViews.html#//apple_ref/doc/uid/TP40008179-CH101-SW14 + UIEdgeInsets insets = UIEdgeInsetsMake(0, 0, /*padding@bottom*/50, 0); + [self setContentInset:insets]; + [self setScrollIndicatorInsets:insets]; +} + +/* +// Only override drawRect: if you perform custom drawing. +// An empty implementation adversely affects performance during animation. +- (void)drawRect:(CGRect)rect +{ + // Drawing code +} +*/ + +@end diff --git a/iBean/iBean/BeanCollectionExtractionViewController.h b/iBean/iBean/BeanCollectionExtractionViewController.h index 4f7a608..1cb0f67 100644 --- a/iBean/iBean/BeanCollectionExtractionViewController.h +++ b/iBean/iBean/BeanCollectionExtractionViewController.h @@ -19,6 +19,9 @@ /* UI Outlets */ @property (weak, nonatomic) IBOutlet UITableView *beanTableView; +@property (weak, nonatomic) IBOutlet UITextView *beanCollectionNoteTextView; +@property (weak, nonatomic) IBOutlet UILabel *extractionProgressLabel; +@property (weak, nonatomic) IBOutlet UIButton *extractionButton; /* UI Actions */ diff --git a/iBean/iBean/BeanCollectionExtractionViewController.m b/iBean/iBean/BeanCollectionExtractionViewController.m index e89324c..4c26ab6 100644 --- a/iBean/iBean/BeanCollectionExtractionViewController.m +++ b/iBean/iBean/BeanCollectionExtractionViewController.m @@ -7,6 +7,7 @@ // #import "BeanCollectionExtractionViewController.h" +#import "BeanCollectionInfoViewController.h" #import "BeanCollection+Interface.h" #import "BeanCell.h" #import "Bean+Interface.h" @@ -30,12 +31,14 @@ { [super viewDidLoad]; // Do any additional setup after loading the view. + } - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [self initViewController]; + } - (void)didReceiveMemoryWarning @@ -44,6 +47,15 @@ // Dispose of any resources that can be recreated. } +- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender +{ + if ([segue.identifier isEqualToString:@"EditBeanCollectionSegue"]) + { + BeanCollectionInfoViewController *infoViewController = (BeanCollectionInfoViewController *)[[segue.destinationViewController viewControllers] objectAtIndex:0]; + [infoViewController initWithModeAndBeanCollection:YES :self.beanCollection]; + } +} + /***************************************************** Utility methods *****************************************************/ @@ -51,7 +63,25 @@ - (void) initViewController { NSLog(@"BeanCollectionExtraction - initViewController"); - self.navigationItem.title = self.beanCollection.name; + if (self.beanCollection != nil) + { + self.navigationItem.title = self.beanCollection.name; + self.extractionProgressLabel.text = [self.beanCollection.extractionTime stringValue]; + + if (![self.beanCollection.note isEqualToString:@""]) + { + self.beanCollectionNoteTextView.text = self.beanCollection.note; + } + else + { + NSLog(@"Note is empty!"); + [self.beanCollectionNoteTextView setHidden:YES]; + } + } + else + { +#warning TODO - Add an error message? + } } - (void) initWithBeanCollection:(BeanCollection *)bc @@ -89,7 +119,6 @@ Bean *currentBean = [self.beanCollection.beans objectAtIndex:indexPath.row]; [cell initWithNameGrindSettingAndAmount:currentBean.name :currentBean.grindSetting :currentBean.amount]; - return cell; } diff --git a/iBean/iBean/iPhoneStoryboard.storyboard b/iBean/iBean/iPhoneStoryboard.storyboard index f496545..df40f8a 100644 --- a/iBean/iBean/iPhoneStoryboard.storyboard +++ b/iBean/iBean/iPhoneStoryboard.storyboard @@ -641,95 +641,143 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + + - - - - - - - + + + + + + + + Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda. + + + + + + + + + + + + + + + + + - + - - - + + + + + + + + - + + + + + + + + @@ -772,10 +820,16 @@ + + + + + + @@ -839,6 +893,7 @@ + \ No newline at end of file -- cgit v1.2.3