Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
lijingcheng
committed
Jul 18, 2016
1 parent
faefe38
commit 2126223
Showing
11 changed files
with
207 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// | ||
// JCTableViewCell.h | ||
// JCTagListView | ||
// | ||
// Created by 李京城 on 16/7/18. | ||
// Copyright © 2016年 lijingcheng. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
#import "JCTagListView.h" | ||
|
||
@interface JCTableViewCell : UITableViewCell | ||
|
||
@property (nonatomic, copy) NSArray *tags; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// | ||
// JCTableViewCell.m | ||
// JCTagListView | ||
// | ||
// Created by 李京城 on 16/7/18. | ||
// Copyright © 2016年 lijingcheng. All rights reserved. | ||
// | ||
|
||
#import "JCTableViewCell.h" | ||
|
||
@interface JCTableViewCell () | ||
|
||
@property (nonatomic, weak) IBOutlet JCTagListView *tagListView; | ||
|
||
@end | ||
|
||
@implementation JCTableViewCell | ||
|
||
- (void)setTags:(NSArray *)tags | ||
{ | ||
_tags = tags; | ||
|
||
self.tagListView.tags = [NSMutableArray arrayWithArray:tags]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// | ||
// JCTableViewController.h | ||
// JCTagListView | ||
// | ||
// Created by 李京城 on 16/7/18. | ||
// Copyright © 2016年 lijingcheng. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface JCTableViewController : UITableViewController | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// | ||
// JCTableViewController.m | ||
// JCTagListView | ||
// | ||
// Created by 李京城 on 16/7/18. | ||
// Copyright © 2016年 lijingcheng. All rights reserved. | ||
// | ||
|
||
#import "JCTableViewController.h" | ||
#import "JCTableViewCell.h" | ||
#import "JCCollectionViewTagFlowLayout.h" | ||
|
||
@interface JCTableViewController () | ||
|
||
@property (nonatomic, copy) NSArray *allTags; | ||
@property (nonatomic, strong) NSMutableArray *cellHeights; | ||
|
||
@property (nonatomic, strong) JCCollectionViewTagFlowLayout *layout; | ||
|
||
@end | ||
|
||
@implementation JCTableViewController | ||
|
||
- (void)viewDidLoad { | ||
[super viewDidLoad]; | ||
|
||
self.cellHeights = [NSMutableArray array]; | ||
self.layout = [[JCCollectionViewTagFlowLayout alloc] init]; | ||
|
||
self.tableView.tableFooterView = [UIView new]; | ||
|
||
self.allTags = @[@[@"NSString", @"NSMutableString", @"NSArray", @"UIAlertView", @"UITapGestureRecognizer", @"IBOutlet", @"IBAction", @"id", @"UIView", @"UIStatusBar", @"UITableViewController", @"UIStepper", @"UISegmentedControl", @"UICollectionViewController", @"UISearchBar", @"UIToolbar", @"UIPageControl"], @[@"UIActionSheet", @"NSMutableArray", @"NSDictionary", @"NSMutableDictionary", @"NSSet", @"NSMutableSet", @"NSData", @"NSMutableData", @"NSDate", @"UICollectionView", @"UIViewController", @"NSCalendar"], @[@"UITextField", @"UITextView", @"UIImageView", @"UITableView"], @[@"UIButton", @"UILabel"]]; | ||
|
||
for (NSArray *tags in self.allTags) { | ||
[self.cellHeights addObject:@([self.layout calculateContentHeight:tags])]; | ||
} | ||
} | ||
|
||
#pragma mark - Table view data source | ||
|
||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { | ||
return self.allTags.count; | ||
} | ||
|
||
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath | ||
{ | ||
return [self.cellHeights[indexPath.row] floatValue]; | ||
} | ||
|
||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { | ||
JCTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellId" forIndexPath:indexPath]; | ||
cell.tags = self.allTags[indexPath.row]; | ||
|
||
return cell; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters