Problem in selecting a line - UITableView
Good Afternoon,<br/>
I have a problem in selecting items brought through the filter
UISearchBar in a UITableView. When I select the item brought by
query, the selected item appears with the name of 1º record. I
using in a customization table that allows me to display
multiple columns.<br/>
Table:

    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 

        return 1; 
    } 
    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 

        return [searched count]; 
    } 
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath (NSIndexPath *)indexPath { 

        NSString *MyIdentifier = [NSString stringWithFormat:@"MyIdentifier %i", indexPath.row]; 
        Grade *cell = (Grade *)[tableView dequeueReusableCellWithIdentifier:MyIdentifier]; 
        tv.autoresizesSubviews = YES; 
             
        if (cell == nil) { 
                    
                cell = [[[Grade alloc] initWithFrame:CGRectZero reuseIdentifier:MyIdentifier] autorelease]; 
        } 
            
        UILabel *label = [[[UILabel alloc] initWithFrame:CGRectMake(0.0, 0, 80.0, tableView.rowHeight)] autorelease]; 

        [cell addColumn:100]; 
        label.tag = LABEL_TAG; 
        label.font = [UIFont systemFontOfSize:14.0]; 
        label.text = [searched objectAtIndex:indexPath.row]; 
        label.textAlignment = UITextAlignmentRight; 
        label.textColor = [UIColor blackColor]; 
        label.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleHeight; 
        [cell.contentView addSubview:label]; 

        label =  [[[UILabel alloc] initWithFrame:CGRectMake(110.0, 0, 80.0, tableView.rowHeight)] autorelease]; 
        [cell addColumn:170]; 
        label.tag = VALUE_TAG; 
        label.font = [UIFont systemFontOfSize:14.0]; 
        label.text = [searched objectAtIndex:indexPath.row]; 
        label.textAlignment = UITextAlignmentRight; 
        label.textColor = [UIColor blackColor]; 
        label.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleHeight; 
        [cell.contentView addSubview:label]; 
            
        return cell; 
    }
Search:

    - (void) search:(NSString *) matchString {
        
    	NSString *upString = [matchString uppercaseString];
    	
        if (searched) {
            
            [searched release];
        }
        
    	searched = [[NSMutableArray alloc] init];
        
    	for (NSString *line in itemsList) {
            
    		if ([matchString length] == 0) {
                
    			[searched addObject:line];
    			continue;
    		}
    		
    		NSRange range = [[line uppercaseString] rangeOfString:upString];
            
    		if (range.location != NSNotFound) {
                
                [searched addObject:line];
            }
    	}
    	
    	[tv reloadData];
    }
    
    #pragma mark UISearchBarDelegate
    
    - (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText {
        
    	[self search:searchText];
    }
    
    - (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar {
        
    	[searchBar resignFirstResponder];
    }
    
    - (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar {
        
    	[searchBar resignFirstResponder];
    }
Grid:

    - (id)initWithFrame:(CGRect)frame reuseIdentifier:(NSString *)reuseIdentifier {
        
    	if (self == [super initWithFrame:frame reuseIdentifier:reuseIdentifier]) {
    		
            // Initialization code
    		columns = [NSMutableArray arrayWithCapacity:5];
    		[columns retain];
    	}
        
    	return self;
    }
    
    - (void)addColumn:(CGFloat)position {
        
    	[columns addObject:[NSNumber numberWithFloat:position]];
    }
    
    - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
        
    	[super setSelected:selected animated:animated];
        
    	// Configure the view for the selected state
    }
    
    - (void)drawRect:(CGRect)rect { 
        
    	CGContextRef ctx = UIGraphicsGetCurrentContext();
    	
    	// just match the color and size of the horizontal line
    	CGContextSetRGBStrokeColor(ctx, 0.5, 0.5, 0.5, 1.0); 
    	CGContextSetLineWidth(ctx, 0.25);
        
    	for (int i = 0; i < [columns count]; i++) {
            
    		// get the position for the vertical line
    		CGFloat f = [((NSNumber*) [columns objectAtIndex:i]) floatValue];
    		CGContextMoveToPoint(ctx, f, 0);
    		CGContextAddLineToPoint(ctx, f, self.bounds.size.height);
    	}
    	
    	CGContextStrokePath(ctx);
    	
    	[super drawRect:rect];
    } 
    
    - (void)dealloc {
        
    	[super dealloc];
    	[columns dealloc];
    }
I need a suggestion on how to solve this problem.


Problem in selecting a line - UITableView
===

Good Afternoon,<br/>
I have a problem in selecting items brought through the filter
UISearchBar in a UITableView. When I select the item brought by
query, the selected item appears with the name of 1º record. I
using in a customization table that allows me to display
multiple columns.<br/>
Table:

    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 

        return 1; 
    } 
    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 

        return [searched count]; 
    } 
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath (NSIndexPath *)indexPath { 

        NSString *MyIdentifier = [NSString stringWithFormat:@"MyIdentifier %i", indexPath.row]; 
        Grade *cell = (Grade *)[tableView dequeueReusableCellWithIdentifier:MyIdentifier]; 
        tv.autoresizesSubviews = YES; 
             
        if (cell == nil) { 
                    
                cell = [[[Grade alloc] initWithFrame:CGRectZero reuseIdentifier:MyIdentifier] autorelease]; 
        } 
            
        UILabel *label = [[[UILabel alloc] initWithFrame:CGRectMake(0.0, 0, 80.0, tableView.rowHeight)] autorelease]; 

        [cell addColumn:100]; 
        label.tag = LABEL_TAG; 
        label.font = [UIFont systemFontOfSize:14.0]; 
        label.text = [searched objectAtIndex:indexPath.row]; 
        label.textAlignment = UITextAlignmentRight; 
        label.textColor = [UIColor blackColor]; 
        label.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleHeight; 
        [cell.contentView addSubview:label]; 

        label =  [[[UILabel alloc] initWithFrame:CGRectMake(110.0, 0, 80.0, tableView.rowHeight)] autorelease]; 
        [cell addColumn:170]; 
        label.tag = VALUE_TAG; 
        label.font = [UIFont systemFontOfSize:14.0]; 
        label.text = [searched objectAtIndex:indexPath.row]; 
        label.textAlignment = UITextAlignmentRight; 
        label.textColor = [UIColor blackColor]; 
        label.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleHeight; 
        [cell.contentView addSubview:label]; 
            
        return cell; 
    }
Search:

    - (void) search:(NSString *) matchString {
        
    	NSString *upString = [matchString uppercaseString];
    	
        if (searched) {
            
            [searched release];
        }
        
    	searched = [[NSMutableArray alloc] init];
        
    	for (NSString *line in itemsList) {
            
    		if ([matchString length] == 0) {
                
    			[searched addObject:line];
    			continue;
    		}
    		
    		NSRange range = [[line uppercaseString] rangeOfString:upString];
            
    		if (range.location != NSNotFound) {
                
                [searched addObject:line];
            }
    	}
    	
    	[tv reloadData];
    }
    
    #pragma mark UISearchBarDelegate
    
    - (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText {
        
    	[self search:searchText];
    }
    
    - (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar {
        
    	[searchBar resignFirstResponder];
    }
    
    - (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar {
        
    	[searchBar resignFirstResponder];
    }
Grid:

    - (id)initWithFrame:(CGRect)frame reuseIdentifier:(NSString *)reuseIdentifier {
        
    	if (self == [super initWithFrame:frame reuseIdentifier:reuseIdentifier]) {
    		
            // Initialization code
    		columns = [NSMutableArray arrayWithCapacity:5];
    		[columns retain];
    	}
        
    	return self;
    }
    
    - (void)addColumn:(CGFloat)position {
        
    	[columns addObject:[NSNumber numberWithFloat:position]];
    }
    
    - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
        
    	[super setSelected:selected animated:animated];
        
    	// Configure the view for the selected state
    }
    
    - (void)drawRect:(CGRect)rect { 
        
    	CGContextRef ctx = UIGraphicsGetCurrentContext();
    	
    	// just match the color and size of the horizontal line
    	CGContextSetRGBStrokeColor(ctx, 0.5, 0.5, 0.5, 1.0); 
    	CGContextSetLineWidth(ctx, 0.25);
        
    	for (int i = 0; i < [columns count]; i++) {
            
    		// get the position for the vertical line
    		CGFloat f = [((NSNumber*) [columns objectAtIndex:i]) floatValue];
    		CGContextMoveToPoint(ctx, f, 0);
    		CGContextAddLineToPoint(ctx, f, self.bounds.size.height);
    	}
    	
    	CGContextStrokePath(ctx);
    	
    	[super drawRect:rect];
    } 
    
    - (void)dealloc {
        
    	[super dealloc];
    	[columns dealloc];
    }
I need a suggestion on how to solve this problem.

