16

Possible Duplicate:
UITableView Cell expand on click

i need help in UITableViewCell of UITableView.My requirement is below:

enter image description here

look at Retweets , list and More when i click retweet following appears enter image description here

you can see that retweet expands and shows other listing and list and more slide below. i want to make the same . Any type of help is highly appreciated ,tutorial link or anything . thank you

Community
  • 1
  • 1
Kshitiz Ghimire
  • 1,716
  • 3
  • 18
  • 37

4 Answers4

20

You may also find this sample code from Apple, helpful.

Vin
  • 10,517
  • 10
  • 58
  • 71
  • i have checkout your link , yes it is almost what i wanted,but it is a large program , so i am searching for alternative ,if not found anything , will definitely go with your idea. thanks a lot man , really appreciate it – Kshitiz Ghimire Mar 04 '11 at 07:04
  • @Kshitizyou can also achieve the functionality by using custom cells easily, but my experience says the smooth experience that you'd get by this method wouldn't be achievable by that one. – Vin Mar 04 '11 at 07:07
  • thaken that in account , thank you once again – Kshitiz Ghimire Mar 04 '11 at 07:10
  • you ans is accepted man , at least i have place to start and there is what i want , i couldn't know what other guy is taking about – Kshitiz Ghimire Mar 04 '11 at 08:07
8

I have implemented a similar one by using tableview header.

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    UIView *customView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 32)];
    UIButton *sectionButton = [UIButton buttonWithType:UIButtonTypeCustom];
    sectionButton.tag = section;
    sectionButton.frame = customView.frame;
    [sectionButton addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];

    UILabel *titleLabel = [[[UILabel alloc] initWithFrame:CGRectMake(0, 0, 320, 32)] autorelease];
    titleLabel.textAlignment = UITextAlignmentCenter;
    titleLabel.backgroundColor = [UIColor clearColor];
    titleLabel.font = [UIFont boldSystemFontOfSize:13];
    titleLabel.textColor = [UIColor whiteColor];

    NSString *tableHeader = @"table_header_down.png";
    switch (section) {
        case 0:
            titleLabel.text = @"Section1";
            tableHeader = showSection1 ? @"table_header_up.png" : @"table_header_down.png";
            break;
        case 1:
            titleLabel.text = @"Section2";
            tableHeader = showSection2 ? @"table_header_up.png" : @"table_header_down.png";
            break;
        case 2:
            titleLabel.text = @"Section3";
            tableHeader = showSection3 ? @"table_header_up.png" : @"table_header_down.png";
            break;
        case 3:
            titleLabel.text = @"Section4";
            tableHeader = showSection4 ? @"table_header_up.png" : @"table_header_down.png";
            break;
        default:
            break;
    }
    [sectionButton setImage:[UIImage imageNamed:tableHeader] forState:UIControlStateNormal];
    [customView addSubview:sectionButton];

    [customView addSubview:titleLabel];

    return [customView autorelease];
}

Then I loaded the cell accordingly to the boolean values corresponding to each section, number of rows returns 0 if Bool 0, and returns the count when Bool 1.

Nithin
  • 6,435
  • 5
  • 43
  • 56
  • i am late now , but will definitely check out your solution tomorrow , thanx – Kshitiz Ghimire Mar 08 '11 at 11:58
  • also, I forget to mention one thing, you may need to have some more thing to do in number if rows in section method. Return zero, if the boolean variable corresponding to that section is zero. In the button pressed method, I am switching the flag of the section between 0 and 1. – Nithin Mar 15 '11 at 12:16
2

If you are an Apple developer, go to the WWDC videos and check out the advanced TableView video. It describes how to do exactly what you are asking about.

Jamie
  • 5,090
  • 28
  • 26
1

i thought this applelink helps you it's the great example of table view

Piyush
  • 244
  • 1
  • 2
  • 8