0
我有一個索引表視圖,按照它們的第一個字母組織城市。我工作的是一個NSMutableDictionary是用A,B,C等關鍵字創建的。並將相應的城市添加到它們各自的陣列中。例如:UITableView索引
Y = (
Yatesboro,
Yeagertown,
York,
"York Haven",
"York New Salem",
"York Springs",
Youngstown,
Youngsville,
Youngwood,
Yukon
);
Z = (
Zelienople,
Zieglerville,
"Zion Grove",
Zionhill,
Zionsville,
Zullinger
);
現在,我的表視圖負荷與區段內的正確節數和行和索引控制正常工作與此:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return [cities count];
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
if([searchArray count]==0)
return @"";
return [searchArray objectAtIndex:section];
}
// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [[cities objectForKey:[searchArray objectAtIndex:section]] count];
}
- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index {
NSLog([NSString stringWithFormat:@"clicked index : %i",index]);
if (index == 0) {
[tableView scrollRectToVisible:[[tableView tableHeaderView] bounds] animated:NO];
return -1;
}
return index;
}
我的問題是現在填充文本表格單元格與每個部分的文本...有關我如何獲取這些信息的任何想法?
工作就像一個魅力男人。給我留下了很大的頭痛。謝謝! – rson 2009-11-03 13:56:36