views:

154

answers:

1

Hi,

I am able to show a index on the right side similar to songs view on the ipod. During searching the index bar gets minimized automatically. And when i go back to my actual table view the index size is small and it displays only few alphabets. How to stop the resizing of this ?

+2  A: 

you have to place proper delegate methods of UITableView in your viewController.m file.

for example I have placed following code.

Please read comments carefully.

#pragma mark -
#pragma mark Table view data source

// an array count which has values for index - like A,B,C etc.
// Customize the number of sections in the table view.
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    //return [NSArray arrayWithArray:keys];
    return [keys count];
}
// an array which has values for index - like A,B,C etc.
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView{
    return keys;
}
// return how many number of rows are required for each section.
// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return [[dMain valueForKey:[keys objectAtIndex:section]] count];
}

// return title of section
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
    return [keys objectAtIndex:section];
}

// create each row for different sections
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    NSString *CellIdentifier = [NSString stringWithFormat:@"%i %i",indexPath.row,indexPath.section];

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
        cell.textLabel.font=[UIFont fontWithName:@"Helvetica" size:12];
        //cell.textLabel.text=[[[objects objectAtIndex:indexPath.row] valueForKey:@"marketname"] stringByReplacingOccurrencesOfString:@"_and_" withString:@"&"];

        cell.textLabel.text=[[[[dMain valueForKey:[keys objectAtIndex:indexPath.section]] objectAtIndex:indexPath.row] valueForKey:@"marketname"] stringByReplacingOccurrencesOfString:@"_and_" withString:@"&"];
    }

    return cell;
}
sugar