117 lines
3.0 KiB
Objective-C
117 lines
3.0 KiB
Objective-C
//
|
|
// TLMenuViewController.m
|
|
// TLChat
|
|
//
|
|
// Created by 李伯坤 on 16/2/6.
|
|
// Copyright © 2016年 李伯坤. All rights reserved.
|
|
//
|
|
|
|
#import "TLMenuViewController.h"
|
|
#import <MobClick.h>
|
|
|
|
@interface TLMenuViewController ()
|
|
|
|
@end
|
|
|
|
@implementation TLMenuViewController
|
|
|
|
- (void) loadView
|
|
{
|
|
self.view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, WIDTH_SCREEN, HEIGHT_SCREEN)];
|
|
self.tableView = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
|
|
[self.tableView setBackgroundColor:[UIColor colorGrayBG]];
|
|
[self.tableView setLayoutMargins:UIEdgeInsetsMake(0, 15, 0, 0)];
|
|
[self.tableView setSeparatorInset:UIEdgeInsetsMake(0, 15, 0, 0)];
|
|
[self.tableView setSeparatorColor:[UIColor colorGrayLine]];
|
|
[self.tableView setTableFooterView:[[UIView alloc] initWithFrame:CGRectMake(0, 0, WIDTH_SCREEN, 20)]];
|
|
}
|
|
|
|
- (void) viewDidLoad
|
|
{
|
|
[super viewDidLoad];
|
|
|
|
[self.tableView registerClass:[TLMenuCell class] forCellReuseIdentifier:@"TLMenuCell"];
|
|
}
|
|
|
|
- (void)viewWillAppear:(BOOL)animated
|
|
{
|
|
[super viewWillAppear:animated];
|
|
[MobClick beginLogPageView:self.analyzeTitle];
|
|
}
|
|
|
|
- (void)viewWillDisappear:(BOOL)animated
|
|
{
|
|
[super viewWillDisappear:animated];
|
|
[MobClick endLogPageView:self.analyzeTitle];
|
|
}
|
|
|
|
- (void)dealloc
|
|
{
|
|
#ifdef DEBUG_MEMERY
|
|
NSLog(@"dealloc %@", self.navigationItem.title);
|
|
#endif
|
|
}
|
|
|
|
#pragma mark -
|
|
#pragma mark - UITableViewDataSource
|
|
- (NSInteger) numberOfSectionsInTableView:(UITableView *)tableView
|
|
{
|
|
return self.data.count;
|
|
}
|
|
|
|
- (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
|
|
{
|
|
return [self.data[section] count];
|
|
}
|
|
|
|
- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
|
|
{
|
|
TLMenuCell *cell = [tableView dequeueReusableCellWithIdentifier:@"TLMenuCell"];
|
|
TLMenuItem *item = [self.data[indexPath.section] objectAtIndex:indexPath.row];
|
|
[cell setMenuItem:item];
|
|
return cell;
|
|
}
|
|
|
|
#pragma mark UITableViewDelegate
|
|
- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
|
|
{
|
|
TLMenuItem *item = [self.data[indexPath.section] objectAtIndex:indexPath.row];
|
|
|
|
if (item.rightIconURL != nil || item.subTitle != nil) {
|
|
item.rightIconURL = nil;
|
|
item.subTitle = nil;
|
|
item.showRightRedPoint = NO;
|
|
[tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
|
|
}
|
|
else {
|
|
[tableView deselectRowAtIndexPath:indexPath animated:NO];
|
|
}
|
|
}
|
|
|
|
- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
|
|
{
|
|
return 44.0f;
|
|
}
|
|
|
|
- (CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
|
|
{
|
|
return 15.0f;
|
|
}
|
|
|
|
- (CGFloat) tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
|
|
{
|
|
return 5.0f;
|
|
}
|
|
|
|
#pragma mark - Getter -
|
|
#pragma mark - Getter -
|
|
- (NSString *)analyzeTitle
|
|
{
|
|
if (_analyzeTitle == nil) {
|
|
return self.navigationItem.title;
|
|
}
|
|
return _analyzeTitle;
|
|
}
|
|
|
|
@end
|