-1

how to manage cellForRowAtindexPath Value for TableViewIndexSearch my code is :

- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView {

    alphabetDict = [NSDictionary dictionaryWithObject:tempArray forKey:@"alphabet"];

    NSLog(@"alphabetDict Is: %@", alphabetDict);

    [listArray  addObject:alphabetDict];

    NSLog(@"listArray Is: %@", listArray);

    return tempArray;

} 

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView

{      
    return 26; 
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {

    UIView *headerView = [[[UIView alloc] initWithFrame:CGRectMake(0,0,tableView.frame.size.width,30)] autorelease];



    UILabel *headerLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, -5, headerView.frame.size.width-120.0, headerView.frame.size.height)];


    for(section ; section <=[self.tempArray count];section++)

    {

        headerLabel.textAlignment = UITextAlignmentLeft;


        headerLabel.text = [self.tempArray objectAtIndex:section];

        headerLabel.textColor = [UIColor whiteColor];

        headerLabel.backgroundColor = [UIColor clearColor];

        headerLabel.font = [UIFont fontWithName:@"Verdana Bold" size:11];

        [headerView setBackgroundColor:[UIColor orangeColor]];

//        NSLog(@"headerLabel.text:%@", headerLabel.text);
        [headerView addSubview:headerLabel];

        [headerLabel release];


        return headerView;

    } 

    return headerView;

}


-(float)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {



    return  23.0;

}

// --------- TableView Delegate and DataSource-----------

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

{
    return [xmlParseArray count];

}


// Customize the appearance of table view cells.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{

    static NSString *CellIdentifier = @"Cell";

    DirectoryCustomCell *directoryCustomCell =(DirectoryCustomCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (directoryCustomCell == nil) {

        directoryCustomCell = [[[DirectoryCustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];

        directoryCustomCell.selectionStyle = UITableViewCellEditingStyleNone;


    }

    UIImageView *searchImg = [[UIImageView alloc]initWithFrame:CGRectMake(292, 0, 28, 360)];

    searchImg.image = [UIImage imageNamed:@"searchindex.png"];

    [directoryCustomCell addSubview:searchImg];



    NSString *companyName = [[xmlParseArray objectAtIndex:indexPath.row ]objectForKey:@"firstname"];
//    NSLog(@"companyName :%@",companyName);

    NSString *flName = [[xmlParseArray objectAtIndex:indexPath.row ]objectForKey:@"title"];

    [directoryCustomCell setDataForEvent1:companyName venue:flName];



    return directoryCustomCell;

}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {

    return [[collation sectionTitles] objectAtIndex:section];

}

- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index {

    return [collation sectionForSectionIndexTitleAtIndex:index];

}

I want to show in sorted form (I mean section headertitle A have the name start from A and so on).

Between Headertitle from A to B these data are common in every section but I want only those starts from A in SectionHeadertitle A and starts from B in headertitle B.

halfer
  • 19,824
  • 17
  • 99
  • 186
Allen
  • 11
  • 1
  • 6

1 Answers1

0
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{
    switch(indexPath.section)
{
// Configure based on section
// Get details corresponding to section
}
    // configure cell and return cell
}

Take a look at this tutorial

visakh7
  • 26,380
  • 8
  • 55
  • 69
  • thanks for helping but my section are generated According alphabet (SectionHeaderTitle from A to Z)how can i manage that how many rows are in headertitle A. i am sending screen shot to you please help – Allen May 26 '11 at 11:17
  • get the starting character for each item and populate based on that – visakh7 May 26 '11 at 11:19
  • sorry i cant understand please give some line of code. I am new in iphone and also data are dynamic – Allen May 26 '11 at 11:28
  • Go through this you will have a brief idea http://stackoverflow.com/questions/2971995/iphone-contacts-app-styled-indexed-table-view-implementation – visakh7 May 26 '11 at 11:32