Latest0.9
Homepagehttps://github.com/xzjxylophone/RXTableViewItem
LicenseMIT
Platformsios 7.0, requires ARC
FrameworksFoundation, UIKit
Authors

TestCell

@interface TestCell ()
@property (weak, nonatomic) IBOutlet UILabel *lblTitle;
@end
@implementation TestCell
- (void)setData:(id)data
{
    if ([data isKindOfClass:[RXFunctionItem class]]) {
        RXFunctionItem *tmp = data;
        self.lblTitle.text = tmp.title;
    }
}
- (void)awakeFromNib {
    // Initialization code
    self.lblTitle.backgroundColor = [UIColor redColor];
}
+ (CGFloat)cellHeight
{
    return 50;
}
@end

VC:

#pragma mark - UITableViewDataSource
#pragma mark Required
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.functionItems.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    id item = self.functionItems[indexPath.row];
    NSString *identify = [TestCell identifier];
    TestCell *cell = (TestCell *)[tableView dequeueReusableCellWithIdentifier:identify];
    if (cell == nil) {
        cell = [TestCell cell_xib];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    [cell setData:item];
    return cell;
}
#pragma mark - UITableViewDelegate
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return [TestCell cellHeight];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    RXFunctionItem *item = self.functionItems[indexPath.row];
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    if (item.action != nil) {
        [self performSelector:item.action withObject:item afterDelay:0];
    }
}
#pragma mark - Action
- (void)cell0Action:(id)sender
{
    NSLog(@"cell0Action:%@", sender);
}
- (void)cell1Action:(id)sender
{
    NSLog(@"cell1Action:%@", sender);
}
- (void)cell2Action:(id)sender
{
    NSLog(@"cell2Action:%@", sender);
}
#pragma mark - View Life Cycle
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    RXFunctionItem *item0 = [[RXFunctionItem alloc] initWithIconName:@"" title:@"第1行" action:@selector(cell0Action:) type:0 object:nil];
    RXFunctionItem *item1 = [[RXFunctionItem alloc] initWithIconName:@"" title:@"第2行" action:@selector(cell1Action:) type:0 object:nil];
    RXFunctionItem *item2 = [[RXFunctionItem alloc] initWithIconName:@"" title:@"第3行" action:@selector(cell2Action:) type:0 object:nil];
    self.functionItems = @[item0, item1, item2];
    [self.tableView reloadData];
}

参考:http://www.cnblogs.com/xzjxylophone/p/4981097.html

Latest podspec

{
    "name": "RXTableViewItem",
    "version": "0.9",
    "license": "MIT",
    "summary": "RXTableViewItem is a relate tableview items",
    "homepage": "https://github.com/xzjxylophone/RXTableViewItem",
    "authors": {
        "Rush.D.Xzj": "[email protected]"
    },
    "social_media_url": "http://weibo.com/xzjxylophone",
    "source": {
        "git": "https://github.com/xzjxylophone/RXTableViewItem.git",
        "tag": "v0.9"
    },
    "description": "RXTableViewItem is a relate tableview items.",
    "source_files": "RXTableViewItem/*.{h,m}",
    "frameworks": [
        "Foundation",
        "UIKit"
    ],
    "requires_arc": true,
    "platforms": {
        "ios": "7.0"
    }
}

Pin It on Pinterest

Share This