From 9e59eb7a57180fe876fd330661977477794422ab Mon Sep 17 00:00:00 2001 From: Nguyen Huy Toan Date: Mon, 16 Jan 2012 06:36:45 +0800 Subject: [PATCH 1/2] refactor InfoLabel into a separate class --- KNPathTableViewController/KNInfoLabel.h | 24 +++++++ KNPathTableViewController/KNInfoLabel.m | 59 ++++++++++++++++++ .../KNPathTableViewController.h | 13 +--- .../KNPathTableViewController.m | 43 +++++-------- .../project.pbxproj | 22 ++----- .../KNFirstViewController.h | 1 - .../KNFirstViewController.m | 18 +++--- .../KNThirdViewController.m | 2 +- KNPathTableViewControllerDemo/first.png | Bin 253 -> 0 bytes KNPathTableViewControllerDemo/first@2x.png | Bin 402 -> 0 bytes KNPathTableViewControllerDemo/second.png | Bin 128 -> 0 bytes KNPathTableViewControllerDemo/second@2x.png | Bin 130 -> 0 bytes 12 files changed, 116 insertions(+), 66 deletions(-) create mode 100644 KNPathTableViewController/KNInfoLabel.h create mode 100644 KNPathTableViewController/KNInfoLabel.m delete mode 100644 KNPathTableViewControllerDemo/first.png delete mode 100644 KNPathTableViewControllerDemo/first@2x.png delete mode 100644 KNPathTableViewControllerDemo/second.png delete mode 100644 KNPathTableViewControllerDemo/second@2x.png diff --git a/KNPathTableViewController/KNInfoLabel.h b/KNPathTableViewController/KNInfoLabel.h new file mode 100644 index 0000000..5ccbaa2 --- /dev/null +++ b/KNPathTableViewController/KNInfoLabel.h @@ -0,0 +1,24 @@ +// +// KNInfoLabel.h +// KNPathTableViewControllerDemo +// +// Created by Toan Nguyen Huy on 16/1/12. +// Copyright (c) 2012 Anideo. All rights reserved. +// + +#import + +#define KNPathTableFadeInDuration 0.3 +#define KNPathTableFadeOutDuration 0.3 +#define KNPathTableFadeOutDelay 0.5 +#define KNPathTableResizeDuration 0.2 +#define KNPathTableSlideInOffset 16.0 + +@interface KNInfoLabel : UIView{ + UIImageView * __bgView; + UILabel * __titleLabel; +} + +@property (nonatomic, retain) NSString *title; + +@end diff --git a/KNPathTableViewController/KNInfoLabel.m b/KNPathTableViewController/KNInfoLabel.m new file mode 100644 index 0000000..27708f1 --- /dev/null +++ b/KNPathTableViewController/KNInfoLabel.m @@ -0,0 +1,59 @@ +// +// KN__titleLabel.m +// KNPathTableViewControllerDemo +// +// Created by Toan Nguyen Huy on 16/1/12. +// Copyright (c) 2012 Anideo. All rights reserved. +// + +#import "KNInfoLabel.h" + + +@implementation KNInfoLabel + +@synthesize title; + +- (id)init +{ + self = [super initWithFrame:CGRectMake(0, 0, 150, 32)]; + if (self) { + __bgView = [[UIImageView alloc] initWithFrame:self.bounds]; + UIImage * overlay = [UIImage imageNamed:@"KNTableOverlay"]; + __bgView.image = [overlay stretchableImageWithLeftCapWidth:overlay.size.width/2.0 + topCapHeight:overlay.size.height/2.0]; + + [self addSubview:__bgView]; + + __titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(16, 4, 140, 20)]; + __titleLabel.font = [UIFont boldSystemFontOfSize:12]; + __titleLabel.textAlignment = UITextAlignmentLeft; + __titleLabel.textColor = [UIColor whiteColor]; + __titleLabel.shadowColor = [UIColor blackColor]; + __titleLabel.backgroundColor = [UIColor clearColor]; + __titleLabel.shadowOffset = CGSizeMake(0, -1); + [self addSubview:__titleLabel]; + } + return self; +} + +- (NSString *) getTitle{ + return __titleLabel.text; +} + +- (void) setTitle:(NSString *)newTitle{ + if (newTitle) { + __titleLabel.text = newTitle; + + CGSize textSize = [newTitle sizeWithFont:__titleLabel.font]; + CGSize newSize = CGSizeMake(textSize.width + 35, textSize.height); + + self.frame = CGRectMake(-newSize.width, + self.frame.origin.y, + newSize.width, + self.frame.size.height); + __bgView.frame = self.bounds; + } +} + + +@end diff --git a/KNPathTableViewController/KNPathTableViewController.h b/KNPathTableViewController/KNPathTableViewController.h index 4c9c2cf..3c51c53 100644 --- a/KNPathTableViewController/KNPathTableViewController.h +++ b/KNPathTableViewController/KNPathTableViewController.h @@ -19,22 +19,15 @@ // #import - -#define KNPathTableFadeInDuration 0.3 -#define KNPathTableFadeOutDuration 0.3 -#define KNPathTableFadeOutDelay 0.5 -#define KNPathTableSlideInOffset 16.0 -#define KNPathTableOverlayDefaultSize CGSizeMake(150, 32) +#import "KNInfoLabel.h" @interface KNPathTableViewController : UIViewController { - UIView * __infoPanel; - CGSize __infoPanelSize; - CGRect __infoPanelInitialFrame; + KNInfoLabel * __infoPanel; CGFloat __initalScrollIndicatorHeight; UITableView * __tableView; } -@property (nonatomic,readonly) UIView * infoPanel; +@property (retain) KNInfoLabel * infoPanel; @property (nonatomic,readonly) UITableView * tableView; -(id)initWithStyle:(UITableViewStyle)style; diff --git a/KNPathTableViewController/KNPathTableViewController.m b/KNPathTableViewController/KNPathTableViewController.m index ed6928c..a16bfc9 100644 --- a/KNPathTableViewController/KNPathTableViewController.m +++ b/KNPathTableViewController/KNPathTableViewController.m @@ -25,13 +25,7 @@ @implementation KNPathTableViewController #pragma mark - Custom init -(id)initWithStyle:(UITableViewStyle)style { - if ((self = [self initWithStyle:style infoPanelSize:KNPathTableOverlayDefaultSize])) { - } - return self; -} - --(id)initWithStyle:(UITableViewStyle)style infoPanelSize:(CGSize)size { - if ((self = [super init])) { + if ((self = [self init])) { // The tableview __tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:style]; __tableView.delegate = self; @@ -39,16 +33,9 @@ -(id)initWithStyle:(UITableViewStyle)style infoPanelSize:(CGSize)size { [self.view addSubview:__tableView]; // The panel - __infoPanelSize = size; - __infoPanelInitialFrame = CGRectMake(-__infoPanelSize.width, 0, __infoPanelSize.width, __infoPanelSize.height); - __infoPanel = [[UIView alloc] initWithFrame:__infoPanelInitialFrame]; - - // Initialize overlay panel with stretchable background - UIImageView * bg = [[UIImageView alloc] initWithFrame:__infoPanel.bounds]; - UIImage * overlay = [UIImage imageNamed:@"KNTableOverlay"]; - bg.image = [overlay stretchableImageWithLeftCapWidth:overlay.size.width/2.0 topCapHeight:overlay.size.height/2.0]; - [__infoPanel setAlpha:0]; - [__infoPanel addSubview:bg]; + __infoPanel = [[KNInfoLabel alloc] init]; + __infoPanel.title = @"Hehe"; + __infoPanel.alpha = 0; } return self; } @@ -87,7 +74,7 @@ - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView { // Add it to indicator [self moveInfoPanelToIndicatorView]; - // Prepare to slide in + // Prepare to slide in CGRect f = __infoPanel.frame; CGRect f2= f; f2.origin.x += KNPathTableSlideInOffset; @@ -97,12 +84,12 @@ - (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView { [self infoPanelWillAppear:scrollView]; [UIView animateWithDuration:KNPathTableFadeInDuration animations:^{ - __infoPanel.alpha = 1; - __infoPanel.frame = f; - } completion:^(BOOL finished) { - [self infoPanelDidAppear:scrollView]; - }]; - } + __infoPanel.alpha = 1; + __infoPanel.frame = f; + } completion:^(BOOL finished) { + [self infoPanelDidAppear:scrollView]; + }]; + } // If it is waiting to fade out, then maintain position else if ([__infoPanel superview] == self.view) { @@ -160,7 +147,7 @@ -(void)moveInfoPanelToSuperView { -(void)moveInfoPanelToIndicatorView { UIView * indicator = [[self.tableView subviews] lastObject]; - CGRect f = __infoPanelInitialFrame; + CGRect f = CGRectMake(-__infoPanel.frame.size.width, 0, __infoPanel.frame.size.width, __infoPanel.frame.size.height); f.origin.y = indicator.frame.size.height/2 - f.size.height/2; if ([__infoPanel superview]) [__infoPanel removeFromSuperview]; [indicator addSubview:__infoPanel]; @@ -193,12 +180,12 @@ - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; - + UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { - cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; + cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; } - + return cell; } diff --git a/KNPathTableViewControllerDemo.xcodeproj/project.pbxproj b/KNPathTableViewControllerDemo.xcodeproj/project.pbxproj index 07ca041..dfde7ea 100644 --- a/KNPathTableViewControllerDemo.xcodeproj/project.pbxproj +++ b/KNPathTableViewControllerDemo.xcodeproj/project.pbxproj @@ -13,17 +13,14 @@ 376B0CFB14BF18800049756D /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 376B0CF914BF18800049756D /* InfoPlist.strings */; }; 376B0CFD14BF18800049756D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 376B0CFC14BF18800049756D /* main.m */; }; 376B0D0114BF18800049756D /* KNAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 376B0D0014BF18800049756D /* KNAppDelegate.m */; }; - 376B0D0614BF18800049756D /* first.png in Resources */ = {isa = PBXBuildFile; fileRef = 376B0D0514BF18800049756D /* first.png */; }; - 376B0D0814BF18800049756D /* first@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 376B0D0714BF18800049756D /* first@2x.png */; }; 376B0D0B14BF18800049756D /* KNSecondViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 376B0D0A14BF18800049756D /* KNSecondViewController.m */; }; - 376B0D0D14BF18800049756D /* second.png in Resources */ = {isa = PBXBuildFile; fileRef = 376B0D0C14BF18800049756D /* second.png */; }; - 376B0D0F14BF18800049756D /* second@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 376B0D0E14BF18800049756D /* second@2x.png */; }; 376B0D1514BF18800049756D /* KNSecondViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 376B0D1314BF18800049756D /* KNSecondViewController.xib */; }; 376B0D2814BF1C6A0049756D /* KNPathTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 376B0D2514BF1C6A0049756D /* KNPathTableViewController.m */; }; 376B0D2914BF1C6A0049756D /* KNTableOverlay.png in Resources */ = {isa = PBXBuildFile; fileRef = 376B0D2614BF1C6A0049756D /* KNTableOverlay.png */; }; 376B0D2A14BF1C6A0049756D /* KNTableOverlay@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 376B0D2714BF1C6A0049756D /* KNTableOverlay@2x.png */; }; 376B0D2E14BF1D400049756D /* KNFirstViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 376B0D2D14BF1D3F0049756D /* KNFirstViewController.m */; }; 376B0D3814BF54F80049756D /* KNThirdViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 376B0D3714BF54F80049756D /* KNThirdViewController.m */; }; + CF84700914C36A980099DEA5 /* KNInfoLabel.m in Sources */ = {isa = PBXBuildFile; fileRef = CF84700814C36A980099DEA5 /* KNInfoLabel.m */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -37,12 +34,8 @@ 376B0CFE14BF18800049756D /* KNPathTableViewControllerDemo-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "KNPathTableViewControllerDemo-Prefix.pch"; sourceTree = ""; }; 376B0CFF14BF18800049756D /* KNAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KNAppDelegate.h; sourceTree = ""; }; 376B0D0014BF18800049756D /* KNAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KNAppDelegate.m; sourceTree = ""; }; - 376B0D0514BF18800049756D /* first.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = first.png; sourceTree = ""; }; - 376B0D0714BF18800049756D /* first@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "first@2x.png"; sourceTree = ""; }; 376B0D0914BF18800049756D /* KNSecondViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KNSecondViewController.h; sourceTree = ""; }; 376B0D0A14BF18800049756D /* KNSecondViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KNSecondViewController.m; sourceTree = ""; }; - 376B0D0C14BF18800049756D /* second.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = second.png; sourceTree = ""; }; - 376B0D0E14BF18800049756D /* second@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "second@2x.png"; sourceTree = ""; }; 376B0D1414BF18800049756D /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/KNSecondViewController.xib; sourceTree = ""; }; 376B0D2414BF1C6A0049756D /* KNPathTableViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KNPathTableViewController.h; sourceTree = ""; }; 376B0D2514BF1C6A0049756D /* KNPathTableViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KNPathTableViewController.m; sourceTree = ""; }; @@ -52,6 +45,8 @@ 376B0D2D14BF1D3F0049756D /* KNFirstViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KNFirstViewController.m; sourceTree = ""; }; 376B0D3614BF54F80049756D /* KNThirdViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KNThirdViewController.h; sourceTree = ""; }; 376B0D3714BF54F80049756D /* KNThirdViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KNThirdViewController.m; sourceTree = ""; }; + CF84700714C36A980099DEA5 /* KNInfoLabel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KNInfoLabel.h; sourceTree = ""; }; + CF84700814C36A980099DEA5 /* KNInfoLabel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KNInfoLabel.m; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -99,10 +94,6 @@ 376B0CF614BF18800049756D /* KNPathTableViewControllerDemo */ = { isa = PBXGroup; children = ( - 376B0D0514BF18800049756D /* first.png */, - 376B0D0714BF18800049756D /* first@2x.png */, - 376B0D0C14BF18800049756D /* second.png */, - 376B0D0E14BF18800049756D /* second@2x.png */, 376B0CFF14BF18800049756D /* KNAppDelegate.h */, 376B0D0014BF18800049756D /* KNAppDelegate.m */, 376B0D2B14BF1D0F0049756D /* KNFirstViewController.h */, @@ -135,6 +126,8 @@ 376B0D2514BF1C6A0049756D /* KNPathTableViewController.m */, 376B0D2614BF1C6A0049756D /* KNTableOverlay.png */, 376B0D2714BF1C6A0049756D /* KNTableOverlay@2x.png */, + CF84700714C36A980099DEA5 /* KNInfoLabel.h */, + CF84700814C36A980099DEA5 /* KNInfoLabel.m */, ); path = KNPathTableViewController; sourceTree = ""; @@ -191,10 +184,6 @@ buildActionMask = 2147483647; files = ( 376B0CFB14BF18800049756D /* InfoPlist.strings in Resources */, - 376B0D0614BF18800049756D /* first.png in Resources */, - 376B0D0814BF18800049756D /* first@2x.png in Resources */, - 376B0D0D14BF18800049756D /* second.png in Resources */, - 376B0D0F14BF18800049756D /* second@2x.png in Resources */, 376B0D1514BF18800049756D /* KNSecondViewController.xib in Resources */, 376B0D2914BF1C6A0049756D /* KNTableOverlay.png in Resources */, 376B0D2A14BF1C6A0049756D /* KNTableOverlay@2x.png in Resources */, @@ -214,6 +203,7 @@ 376B0D2814BF1C6A0049756D /* KNPathTableViewController.m in Sources */, 376B0D2E14BF1D400049756D /* KNFirstViewController.m in Sources */, 376B0D3814BF54F80049756D /* KNThirdViewController.m in Sources */, + CF84700914C36A980099DEA5 /* KNInfoLabel.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/KNPathTableViewControllerDemo/KNFirstViewController.h b/KNPathTableViewControllerDemo/KNFirstViewController.h index b3e70f5..45de68c 100644 --- a/KNPathTableViewControllerDemo/KNFirstViewController.h +++ b/KNPathTableViewControllerDemo/KNFirstViewController.h @@ -11,7 +11,6 @@ @interface KNFirstViewController : KNPathTableViewController { NSMutableArray * array; - UILabel * infoLabel; } @end diff --git a/KNPathTableViewControllerDemo/KNFirstViewController.m b/KNPathTableViewControllerDemo/KNFirstViewController.m index 1f9084e..c3f3d01 100644 --- a/KNPathTableViewControllerDemo/KNFirstViewController.m +++ b/KNPathTableViewControllerDemo/KNFirstViewController.m @@ -29,23 +29,16 @@ -(id)initWithStyle:(UITableViewStyle)style { -(void)viewDidLoad { [super viewDidLoad]; - infoLabel = [[UILabel alloc] initWithFrame:CGRectMake(16, 4, 140, 20)]; - infoLabel.font = [UIFont boldSystemFontOfSize:12]; - infoLabel.textAlignment = UITextAlignmentLeft; - infoLabel.textColor = [UIColor whiteColor]; - infoLabel.shadowColor = [UIColor blackColor]; - infoLabel.backgroundColor = [UIColor clearColor]; - infoLabel.shadowOffset = CGSizeMake(0, 1); + // [self.infoPanel addSubview:infoLabel] // this will not work, too early to add } -(void)infoPanelWillAppear:(UIScrollView *)scrollView { - if (![infoLabel superview]) [self.infoPanel addSubview:infoLabel]; } -(void)infoPanelDidScroll:(UIScrollView *)scrollView atPoint:(CGPoint)point { NSIndexPath * indexPath = [self.tableView indexPathForRowAtPoint:point]; - infoLabel.text = [NSString stringWithFormat:@"Something about %d", indexPath.row]; + self.infoPanel.title = [__tableView cellForRowAtIndexPath:indexPath].textLabel.text; } #pragma mark - Give table some content @@ -66,7 +59,12 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; } - cell.textLabel.text = [array objectAtIndex:indexPath.row]; + if (indexPath.row < 10) { + cell.textLabel.text = [array objectAtIndex:indexPath.row]; + } else { + cell.textLabel.text = [NSString stringWithFormat:@"Row %i", indexPath.row]; + } + return cell; } diff --git a/KNPathTableViewControllerDemo/KNThirdViewController.m b/KNPathTableViewControllerDemo/KNThirdViewController.m index 3ee70e1..e6ffed6 100644 --- a/KNPathTableViewControllerDemo/KNThirdViewController.m +++ b/KNPathTableViewControllerDemo/KNThirdViewController.m @@ -29,7 +29,7 @@ -(id)initWithStyle:(UITableViewStyle)style { -(void)infoPanelDidScroll:(UIScrollView *)scrollView atPoint:(CGPoint)point { NSIndexPath * indexPath = [self.tableView indexPathForRowAtPoint:point]; - infoLabel.text = [NSString stringWithFormat:@"In section %d", indexPath.section+1]; + self.infoPanel.title = [NSString stringWithFormat:@"In section %d", indexPath.section+1]; } #pragma mark - Give table some content diff --git a/KNPathTableViewControllerDemo/first.png b/KNPathTableViewControllerDemo/first.png deleted file mode 100644 index 9300ee2cd85a05d8ab3d300acc09c13829ccb5ce..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 253 zcmeAS@N?(olHy`uVBq!ia0vp^av;pY3?xs=ZJr3EI14-?iy0WWg+Z8+Vb&Z8prA^C zPl)UP|NntZ{NT8nT`EuocS(?6FasltZ*a@vB{%Q?+`Lrc8c;aH)5S4F;&O7r0@i?& zF{WoZ52n7mx3~H`AG5@C!zy!*9MOhPk>$<~3{&!XpXRp}%-pr`k1SV$-RV4u0*22w zAO2x6m@j;8KEt!(gFm@9e7bmb^TL_!dGfoeFWl{ZC|~k_Q9HX^MW7%9gZ;w7yrcIE Q^gxdFboFyt=akR{03BgY=Kufz diff --git a/KNPathTableViewControllerDemo/first@2x.png b/KNPathTableViewControllerDemo/first@2x.png deleted file mode 100644 index 374d78edd0e6d5db42b559bac2178edef037836a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 402 zcmeAS@N?(olHy`uVBq!ia0vp^HXzKw3=&b&bO2JE1s;*b3=CqbAk63)r1AkM=o;V? z;`;ype;|`WAeXrOCC~`5k|4ie21X_}K5=6c-?FCezLl$1U%LPN&9|Skp6V+DRb2FR zaSZV|{&t!t-(dwFhRxG9n7sM-Ke&3WQnRdOsQ#H+mQQxR%?IsgO#P;KeOB}J^*^WW zn#~dKvU&5>v!Xi!?i?%bXW@96u%f$_t!&|)uPtiNz4qKLWW4uxyKc$GyAh0z>RHi? zo?JOMgIVbMn$=FHmxgAuNz8E5cj=S)s26y^Y2l`4C#9y^`hQy?Q&Hsb^vq;qt?+p< z^QXJs7i0CAq7^vN;PmIOHOU=OL1sKI$sT45u8YIXzI2ur>+O#&*(9nR{qE3ar?Lw% i{+gxlr%3V4d&E5TcJ?AMtKADhA?WGq=d#Wzp$Pymd53oZ diff --git a/KNPathTableViewControllerDemo/second.png b/KNPathTableViewControllerDemo/second.png deleted file mode 100644 index 1100b487f2ca4f4b885625ba575c842c210fb73c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 128 zcmeAS@N?(olHy`uVBq!ia0vp^av;pe3?v!<**pYNoCO|{#S9GG!XV7ZFl&wkP>?Oa zC&cyt|NlT{=%LGXAk`&7e!&b5&u*jvIl`VUjv*Y^lM@bb&-nj;xnQF>1H+`lD#BN) SrXB@KGkCiCxvXFVdQ&MBb@0K*?3>;M1& From b669b523011a3ab5ccc20c6f64297fe73e4f2bbc Mon Sep 17 00:00:00 2001 From: Nguyen Huy Toan Date: Mon, 16 Jan 2012 08:29:14 +0800 Subject: [PATCH 2/2] change row names in the demo tableiew --- .../KNFirstViewController.m | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/KNPathTableViewControllerDemo/KNFirstViewController.m b/KNPathTableViewControllerDemo/KNFirstViewController.m index c3f3d01..f5fe866 100644 --- a/KNPathTableViewControllerDemo/KNFirstViewController.m +++ b/KNPathTableViewControllerDemo/KNFirstViewController.m @@ -19,7 +19,15 @@ -(id)initWithStyle:(UITableViewStyle)style { // Add a series of number array = [[NSMutableArray alloc] init]; for (int k=0;k<100;k++) { - [array addObject:[NSString stringWithFormat:@"Test row number %d", k]]; + if(k < 30){ + [array addObject:[NSString stringWithFormat:@"Row %d", k]]; + } + else if(k < 60) { + [array addObject:[NSString stringWithFormat:@"Longer row %d", k]]; + } + else { + [array addObject:[NSString stringWithFormat:@"Even longer row %d", k]]; + } } } return self; @@ -59,11 +67,9 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; } - if (indexPath.row < 10) { - cell.textLabel.text = [array objectAtIndex:indexPath.row]; - } else { - cell.textLabel.text = [NSString stringWithFormat:@"Row %i", indexPath.row]; - } + + cell.textLabel.text = [array objectAtIndex:indexPath.row]; + return cell; }