开发者

How to manage cellForRowAtIndexPath for tableViewIndexSearch?

开发者 https://www.devze.com 2023-03-08 07:44 出处:网络
how to manage cellForRowAtindexPath Value for TableViewIndexSearch my code is : - (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView {

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.f开发者_StackOverflowrame.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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号