Permalink
Browse files

Tableviewcontroller fix for weird navigation controller conditions.

  • Loading branch information...
1 parent cdff3f0 commit e3ae84209d7d2d98279519fdddbd894108cb3ea6 @devinross devinross committed Dec 8, 2010
@@ -51,7 +51,7 @@
@property (nonatomic,assign) id <TKCalendarMonthViewDelegate> delegate;
@property (nonatomic,assign) id <TKCalendarMonthViewDataSource> dataSource;
-- (id) initWithSundayAsFirst:(BOOL)sunday; // it sunday regardless right now...
+- (id) initWithSundayAsFirst:(BOOL)sunday; // or Monday
- (NSDate*) dateSelected;
@@ -37,7 +37,7 @@
@interface TKEmptyView()
- (UIImage*) maskedImageWithImage:(UIImage*)m;
-
+- (UIImage*) predefinedImage:(TKEmptyViewImage)img;
@end
@@ -46,78 +46,8 @@ - (UIImage*) maskedImageWithImage:(UIImage*)m;
@implementation TKEmptyView
@synthesize imageView,titleLabel,subtitleLabel;
-- (UIImage*) predefinedImage:(TKEmptyViewImage)img{
-
- NSString *str;
-
- switch (img) {
- case TKEmptyViewImageChatBubble:
- str = @"chatbubble";
- break;
- case TKEmptyViewImageClock:
- str = @"clock";
- break;
- case TKEmptyViewImageCompass:
- str = @"compass";
- break;
- case TKEmptyViewImageEye:
- str = @"eye";
- break;
- case TKEmptyViewImageHeart:
- str = @"heart";
- break;
- case TKEmptyViewImageMovieClip:
- str = @"movieclip";
- break;
- case TKEmptyViewImageMusicNote:
- str = @"note";
- break;
- case TKEmptyViewImagePhotos:
- str = @"photos";
- break;
- case TKEmptyViewImagePictureFrame:
- str = @"pictureframe";
- break;
- case TKEmptyViewImageSearch:
- str = @"search";
- break;
- case TKEmptyViewImageSign:
- str = @"sign";
- break;
- case TKEmptyViewImageStar:
- str = @"star";
- break;
- case TKEmptyViewImageStopwatch:
- str = @"stopwatch";
- break;
- case TKEmptyViewImageKey:
- str = @"key";
- break;
- case TKEmptyViewImageMale:
- str = @"malePerson";
- break;
- case TKEmptyViewImageTelevision:
- str = @"television";
- break;
- default:
- str = @"star";
- break;
- }
-
- NSString *scale = @"";
- if([[UIScreen mainScreen] respondsToSelector:@selector(scale)]){
- NSInteger s = [[UIScreen mainScreen] scale];
- if(s > 1) scale = @"@2x";
- }
-
- NSString *path = [NSString stringWithFormat:@"TapkuLibrary.bundle/Images/empty/%@%@.png",str,scale];
-
-
- return [UIImage imageWithContentsOfFile:TKBUNDLE(path)];
-}
-
- (id) initWithFrame:(CGRect)frame mask:(UIImage*)image title:(NSString*)titleString subtitle:(NSString*)subtitleString{
if(self = [super initWithFrame:frame]){
@@ -175,19 +105,17 @@ - (void) dealloc {
- (void) drawRect:(CGRect)rect{
-
UIColor *top = [UIColor colorWithRed:242/255.0 green:244/255.0 blue:246/255.0 alpha:1];
UIColor *bot = [UIColor colorWithRed:225/255.0 green:229/255.0 blue:235/255.0 alpha:1];
[UIView drawGradientInRect:rect withColors:[NSArray arrayWithObjects:top,bot,nil]];
}
-
- (void) layoutSubviews{
[super layoutSubviews];
CGRect rect = self.frame;
- titleLabel.frame = CGRectMake(0, 0, rect.size.width, 20);
- subtitleLabel.frame = CGRectMake(0, 0, rect.size.width, 16);
+ titleLabel.frame = CGRectMake(10, 0, rect.size.width-20, 20);
+ subtitleLabel.frame = CGRectMake(10, 0, rect.size.width-20, 16);
imageView.frame = CGRectMake(0, 0, imageView.image.size.width, imageView.image.size.height);
imageView.center = CGPointMake(rect.size.width/2, rect.size.height/2 - rect.size.height/12 );
@@ -233,7 +161,77 @@ - (UIImage*) maskedImageWithImage:(UIImage*)m{
return scaledImage;
}
-
+- (UIImage*) predefinedImage:(TKEmptyViewImage)img{
+
+ NSString *str;
+
+
+
+ switch (img) {
+ case TKEmptyViewImageChatBubble:
+ str = @"chatbubble";
+ break;
+ case TKEmptyViewImageClock:
+ str = @"clock";
+ break;
+ case TKEmptyViewImageCompass:
+ str = @"compass";
+ break;
+ case TKEmptyViewImageEye:
+ str = @"eye";
+ break;
+ case TKEmptyViewImageHeart:
+ str = @"heart";
+ break;
+ case TKEmptyViewImageMovieClip:
+ str = @"movieclip";
+ break;
+ case TKEmptyViewImageMusicNote:
+ str = @"note";
+ break;
+ case TKEmptyViewImagePhotos:
+ str = @"photos";
+ break;
+ case TKEmptyViewImagePictureFrame:
+ str = @"pictureframe";
+ break;
+ case TKEmptyViewImageSearch:
+ str = @"search";
+ break;
+ case TKEmptyViewImageSign:
+ str = @"sign";
+ break;
+ case TKEmptyViewImageStar:
+ str = @"star";
+ break;
+ case TKEmptyViewImageStopwatch:
+ str = @"stopwatch";
+ break;
+ case TKEmptyViewImageKey:
+ str = @"key";
+ break;
+ case TKEmptyViewImageMale:
+ str = @"malePerson";
+ break;
+ case TKEmptyViewImageTelevision:
+ str = @"television";
+ break;
+ default:
+ str = @"star";
+ break;
+ }
+
+ NSString *scale = @"";
+ if([[UIScreen mainScreen] respondsToSelector:@selector(scale)]){
+ NSInteger s = [[UIScreen mainScreen] scale];
+ if(s > 1) scale = @"@2x";
+ }
+
+ NSString *path = [NSString stringWithFormat:@"TapkuLibrary.bundle/Images/empty/%@%@.png",str,scale];
+
+
+ return [UIImage imageWithContentsOfFile:TKBUNDLE(path)];
+}
@@ -73,6 +73,13 @@ - (void) dealloc {
- (void) loadView{
[super loadView];
+
+ _tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:_style];
+ _tableView.delegate = self;
+ _tableView.dataSource = self;
+ _tableView.showsVerticalScrollIndicator = YES;
+ _tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
+
[self.view addSubview:self.tableView];
}
@@ -95,16 +102,6 @@ - (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexP
// -----------------------------
// PROPERTIES
-- (UITableView*) tableView{
- if(_tableView==nil){
- _tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:_style];
- _tableView.delegate = self;
- _tableView.dataSource = self;
- _tableView.showsVerticalScrollIndicator = YES;
- _tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
- }
- return _tableView;
-}
- (TKEmptyView*) emptyView{
if(_emptyView==nil){
_emptyView = [[TKEmptyView alloc] initWithFrame:self.view.bounds
@@ -37,7 +37,7 @@ @implementation TKViewController
- (void)dealloc {
- self.tkBackButton = nil;
+ [_tkBackButton release], _tkBackButton = nil;
[super dealloc];
}
@@ -87,7 +87,7 @@ - (void) generateRandomDataForStartDate:(NSDate*)start endDate:(NSDate*)end{
// dataDictionary: has items that are associated with date keys (for tableview)
- NSLog(@"Delegate Range: %@ %@",start,end);
+ NSLog(@"Delegate Range: %@ %@ %d",start,end,[start daysBetweenDate:end]);
self.dataArray = [NSMutableArray array];
self.dataDictionary = [NSMutableDictionary dictionary];

0 comments on commit e3ae842

Please sign in to comment.