-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathAddressVC.m
More file actions
139 lines (118 loc) · 4.01 KB
/
AddressVC.m
File metadata and controls
139 lines (118 loc) · 4.01 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
//
// AddressVC.m
// DuDu
//
// Created by 教路浩 on 15/12/3.
// Copyright © 2015年 i-chou. All rights reserved.
//
#import "AddressVC.h"
@interface AddressVC ()
{
UITableView *_tableView;
UILabel *_homeLabel;
UILabel *_companyLabel;
}
@end
@implementation AddressVC
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = COLORRGB(0xf0f0f0);
[self createTableView];
}
- (void)createTableView
{
_tableView = [[UITableView alloc] initWithFrame:ccr(0,
NAV_BAR_HEIGHT_IOS7+50,
SCREEN_WIDTH,
60*2)];
_tableView.delegate = self;
_tableView.dataSource = self;
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
_tableView.backgroundColor = COLORRGB(0xffffff);
_tableView.scrollEnabled = NO;
_tableView.contentInset = UIEdgeInsetsMake(-64, 0, 0, 0);
[self.view addSubview:_tableView];
}
#pragma mark - tableView dataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 2;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 60;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *identifier = @"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
}
if (indexPath.row==0) {
[cell addSubview:[self homeLabel]];
} else if (indexPath.row==1) {
[cell addSubview:[self companyLabel]];
}
[cell addSubview:[self bottomLine]];
return cell;
}
#pragma mark - tableView delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
GeoAndSuggestionViewController *addressPickerVC = [[GeoAndSuggestionViewController alloc] init];
addressPickerVC.delegate = self;
[self.navigationController pushViewController:addressPickerVC animated:YES];
if (indexPath.row==0) {
addressPickerVC.title = @"家地址";
addressPickerVC.isFrom = YES;
} else if (indexPath.row==1) {
addressPickerVC.title = @"公司地址";
addressPickerVC.isFrom = NO;
}
}
- (UILabel *)homeLabel
{
_homeLabel = [UILabel labelWithFrame:CGRectZero
color:COLORRGB(0x000000)
font:HSFONT(12)
text:@"输入家地址"
alignment:NSTextAlignmentLeft
numberOfLines:1];
_homeLabel.frame = ccr(10, 0, SCREEN_WIDTH-10*2, 60);
return _homeLabel;
}
- (UILabel *)companyLabel
{
_companyLabel = [UILabel labelWithFrame:CGRectZero
color:COLORRGB(0x000000)
font:HSFONT(12)
text:@"输入公司地址"
alignment:NSTextAlignmentLeft
numberOfLines:1];
_companyLabel.frame = ccr(10, 0, SCREEN_WIDTH-10*2, 60);
return _companyLabel;
}
- (UIImageView *)bottomLine
{
UIImageView *bottomLine = [[UIImageView alloc] initWithFrame:ccr(0, 60-0.5, SCREEN_WIDTH, 0.5)];
bottomLine.backgroundColor = COLORRGB(0xd7d7d7);
return bottomLine;
}
#pragma mark - GeoAndSuggestionViewControllerDelegate
- (void)addressPicker:(GeoAndSuggestionViewController *)pickerVC fromAddress:(QMSSuggestionPoiData *)fromPoi toAddress:(QMSSuggestionPoiData *)toPoi
{
if (fromPoi) {
_homeLabel.text = fromPoi.title;
} else {
_companyLabel.text = toPoi.title;
}
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
@end