简体   繁体   中英

Special TableView in Iphone SDK

在此处输入图片说明

As you see above, I have a Table View on LeftSide which contains a Some Text.

But when i selected any annotation in map according to that the cell will be Highlighted & it has more text rather than other Cell and also background color is changed.

How can i achieve this?

You can approach in following way.
First both table data and annotation pins in Map are filled from an array!! What you can do, you can define "tag" as array index to particular item. When a user tap on a annotation, that annotation has a "tag" (or array index) and this "tag" (or array index) also has an item for table data. On click of annotation tap, you have to reload your table and make that particular tableview cell highlighted.

  1. You need to customize the UITableViewCell for this
  2. Add a table view and map view in your view as shown in figure.
  3. Load the custom table view cell to tableview
  4. Initially give the needed color for all table cells
  5. When user selects a cell change it's color
  6. Using didSelectRowAtIndexPath: delegate method show the corresponding value on map.

Check this link for tutorials:

The basic sample for slide menu in iOS

https://github.com/nverinaud/NVSlideMenuController

Hope this sample code will helps you

I think you are creating custom annotation instead of the default one so if it is possible for you to set tag for each annotation view which will be same as tableview cell index. While selecting an annotation create indexpath with that tag and set selectedrow for that indexpath. Hope it may help you.

  1. Create your customized class of UITableViewCell .
  2. Understand you have two conditions A. Normal Cell B. Cell after the click.

You'll have to use 3 delegate methods of UITableView to achieve this.

- (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.
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM