You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
110 lines
2.9 KiB
110 lines
2.9 KiB
![]()
2 years ago
|
//
|
||
|
// XHBaseTableViewController.m
|
||
|
// MessageDisplayExample
|
||
|
//
|
||
|
// Created by HUAJIE-1 on 14-5-6.
|
||
|
// Copyright (c) 2014年 曾宪华 开发团队(http://iyilunba.com ) 本人QQ:543413507 本人QQ群(142557668). All rights reserved.
|
||
|
//
|
||
|
|
||
|
#import "XHBaseTableViewController.h"
|
||
|
|
||
|
#import "XHFoundationCommon.h"
|
||
|
|
||
|
@interface XHBaseTableViewController ()
|
||
|
|
||
|
/**
|
||
|
* 判断tableView是否支持iOS7的api方法
|
||
|
*
|
||
|
* @return 返回预想结果
|
||
|
*/
|
||
|
- (BOOL)validateSeparatorInset;
|
||
|
|
||
|
@end
|
||
|
|
||
|
@implementation XHBaseTableViewController
|
||
|
|
||
|
#pragma mark - Publish Method
|
||
|
|
||
|
- (void)configuraTableViewNormalSeparatorInset {
|
||
|
if ([self validateSeparatorInset]) {
|
||
|
[_tableView setSeparatorInset:UIEdgeInsetsZero];
|
||
|
}
|
||
|
}
|
||
|
|
||
|
- (void)configuraSectionIndexBackgroundColorWithTableView:(UITableView *)tableView {
|
||
|
if ([tableView respondsToSelector:@selector(setSectionIndexBackgroundColor:)]) {
|
||
|
tableView.sectionIndexBackgroundColor = [UIColor clearColor];
|
||
|
}
|
||
|
}
|
||
|
|
||
|
- (void)loadDataSource {
|
||
|
// subClasse
|
||
|
}
|
||
|
|
||
|
#pragma mark - Propertys
|
||
|
|
||
|
- (UITableView *)tableView {
|
||
|
if (!_tableView) {
|
||
|
CGRect tableViewFrame = self.view.bounds;
|
||
|
tableViewFrame.size.height -= (self.navigationController.viewControllers.count > 1 ? 0 : (CGRectGetHeight(self.tabBarController.tabBar.bounds))) + [XHFoundationCommon getAdapterHeight];
|
||
|
_tableView = [[UITableView alloc] initWithFrame:tableViewFrame style:self.tableViewStyle];
|
||
|
_tableView.delegate = self;
|
||
|
_tableView.dataSource = self;
|
||
|
if (![self validateSeparatorInset]) {
|
||
|
if (self.tableViewStyle == UITableViewStyleGrouped) {
|
||
|
UIView *backgroundView = [[UIView alloc] initWithFrame:_tableView.bounds];
|
||
|
backgroundView.backgroundColor = _tableView.backgroundColor;
|
||
|
_tableView.backgroundView = backgroundView;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
return _tableView;
|
||
|
}
|
||
|
|
||
|
#pragma mark - Life cycle
|
||
|
|
||
|
- (void)viewDidLoad {
|
||
|
[super viewDidLoad];
|
||
|
// Do any additional setup after loading the view.
|
||
|
[self.view addSubview:self.tableView];
|
||
|
}
|
||
|
|
||
|
- (void)dealloc {
|
||
|
self.myDataSource = nil;
|
||
|
self.tableView.delegate = nil;
|
||
|
self.tableView.dataSource = nil;
|
||
|
self.tableView = nil;
|
||
|
}
|
||
|
|
||
|
- (void)didReceiveMemoryWarning {
|
||
|
[super didReceiveMemoryWarning];
|
||
|
// Dispose of any resources that can be recreated.
|
||
|
}
|
||
|
|
||
|
#pragma mark - TableView Helper Method
|
||
|
|
||
|
- (BOOL)validateSeparatorInset {
|
||
|
if ([_tableView respondsToSelector:@selector(setSeparatorInset:)]) {
|
||
|
return YES;
|
||
|
}
|
||
|
return NO;
|
||
|
}
|
||
|
|
||
|
#pragma mark - UITableView DataSource
|
||
|
|
||
|
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
|
||
|
return 1;
|
||
|
}
|
||
|
|
||
|
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
||
|
return self.myDataSource.count;
|
||
|
}
|
||
|
|
||
|
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||
|
// in subClass
|
||
|
return nil;
|
||
|
}
|
||
|
|
||
|
|
||
|
@end
|