-
Notifications
You must be signed in to change notification settings - Fork 0
/
PickCategoryTableViewController.m
77 lines (61 loc) · 1.97 KB
/
PickCategoryTableViewController.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//
// PickCategoryTableViewController.m
// Dandan
//
// Created by on 12-4-3.
// Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//
#import "PickCategoryTableViewController.h"
#import "LocalSQLiteOperate.h"
@interface PickCategoryTableViewController ()
@end
@implementation PickCategoryTableViewController
@synthesize delegate, categories;
- (void)fillCategoryList{
if ([[LocalSQLiteOperate alloc] respondsToSelector:@selector(getCategoryList)])
{
categories = [[LocalSQLiteOperate alloc] performSelector:@selector(getCategoryList)];
} else {
NSLog(@"## Class does not respond to getCategoryList");
}
}
- (void)viewDidLoad
{
[super viewDidLoad];
[self fillCategoryList];
}
- (void)viewDidUnload
{
[super viewDidUnload];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [categories count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil){
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
NSInteger row = [indexPath row];
cell.textLabel.text = [categories objectAtIndex:row];
return cell;
}
#pragma mark - Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self.delegate controller:self didSelectCategory:[categories objectAtIndex:[indexPath row]]];
[self.navigationController popViewControllerAnimated:YES];
}
@end