admin 管理员组文章数量: 1184232
tableview实现静态表格(xib版)
通过xib实现tableview的静态表格,效果如下
关联xib的属性
@interface MyTableViewController ()
@property (strong, nonatomic) IBOutlet UITableViewCell *userInfoCell;
//绿钻
@property (strong, nonatomic) IBOutlet UITableViewCell *greenDiamondCell;
//免流量服务
@property (strong, nonatomic) IBOutlet UITableViewCell *freeDataCell;
//定时关闭
@property (strong, nonatomic) IBOutlet UITableViewCell *ontimeCloseCell;
//退出登录
@property (strong, nonatomic) IBOutlet UITableViewCell *exitCell;@property (weak, nonatomic) IBOutlet UILabel *nicknameLabel;@end
代码实现
- (void)viewDidLoad {[super viewDidLoad];self.nicknameLabel.text = @"小苍";
}- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {return 4;
}- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {if (section == 1) return 2;return 1;
}- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {switch (indexPath.section) {case 0:return self.userInfoCell;case 1:if (indexPath.row == 0) {return self.greenDiamondCell;}else {return self.freeDataCell;}case 2:return self.ontimeCloseCell;default:return self.exitCell;}
}-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {if (indexPath.section == 0) return 80;return 44;
}
自定义cell的xib如下图:
本文标签: tableview实现静态表格(xib版)
版权声明:本文标题:tableview实现静态表格(xib版) 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.roclinux.cn/b/1693755713a240958.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论