【发布时间】:2013-01-01 20:00:16
【问题描述】:
正如您在上面看到的,我在 LeftSide 上有一个表视图,其中包含一些文本。
但是当我在地图中选择任何注释时,单元格将被突出显示并且它有更多的文本而不是其他单元格并且背景颜色也发生了变化。
我怎样才能做到这一点?
【问题讨论】:
标签: iphone ios xcode uitableview map
正如您在上面看到的,我在 LeftSide 上有一个表视图,其中包含一些文本。
但是当我在地图中选择任何注释时,单元格将被突出显示并且它有更多的文本而不是其他单元格并且背景颜色也发生了变化。
我怎样才能做到这一点?
【问题讨论】:
标签: iphone ios xcode uitableview map
您可以通过以下方式接近。
首先,Map 中的表格数据和注释引脚都是从数组中填充的!!
您可以做什么,您可以将“标签”定义为特定项目的数组索引。
当用户点击注释时,该注释有一个“标签”(或数组索引),而这个“标签”(或数组索引)也有一个表数据项。
单击注释点击后,您必须重新加载表格并突出显示特定的表格视图单元格。
【讨论】:
UITableViewCell
didSelectRowAtIndexPath:委托方法在map上显示对应的值。查看此链接以获取教程:
【讨论】:
UITableViewCell & 当我选择任何注释时,将根据该单元格被选中。
heightForRowAtIndexPath:委托方法
【讨论】:
我认为您正在创建自定义注释而不是默认注释,因此如果您可以为每个注释视图设置标签,该标签将与表格视图单元格索引相同。选择注释时,使用该标记创建索引路径并为该索引路径设置 selectedrow。希望对您有所帮助。
【讨论】:
UITableViewCell。您必须使用 UITableView 的 3 个委托方法来实现这一点。
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
// Here you'll have to check for the condition you'll have to check which indexPath.row is selected. and according to that you'll have to change the height of your row.
return hight;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
// Again the same thing. You'll have to check the condition and load the appropriate controls with appropriate frames.
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// This is the important function for you.
// Here you'll have to set one counter. Which you'll use in the
// After that reload the table.
}
【讨论】: