0

从服务器成功请求和解析 xml 文件后,我想在顶部添加一个小搜索栏。因此,在我学习 Objective-ci 时,我遵循了 3 个也许 4 个关于如何制作功能搜索栏的教程,但没有成功。问题是我不知道如何在由 NSXMLParser 填充的 NSMutableArray 中执行排序,请寻求帮助:

这是我打印结果的地方:

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

    static NSString *MyIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];

    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault  reuseIdentifier:MyIdentifier] autorelease];

    CGRect frame = CGRectMake(0, 0, 160, 50);
    UILabel *lbl1 = [[UILabel alloc] initWithFrame:frame];
    lbl1.textAlignment = NSTextAlignmentRight;
    [lbl1 setFont:[UIFont fontWithName:@"Helvetica" size:12.0]];
    [lbl1 setTextColor:[UIColor grayColor]];
    int storyIndex = [indexPath indexAtPosition: [indexPath length] - 1];
    lbl1.text = [[stories objectAtIndex: storyIndex] objectForKey: @"creation_date"];
    [cell.contentView addSubview:lbl1];
    [lbl1 release];

    CGRect frame2 = CGRectMake(0, 0, 250, 50);
    UILabel *lbl2 = [[UILabel alloc] initWithFrame:frame2];
    lbl2.textAlignment = NSTextAlignmentRight;
    [lbl2 setFont:[UIFont fontWithName:@"Helvetica" size:12.0]];
    [lbl2 setTextColor:[UIColor blackColor]];
    lbl2.text = [[stories objectAtIndex: storyIndex] objectForKey: @"name"];
    [cell.contentView addSubview:lbl2];
    [lbl2 release];

    if(!uploaded) 
    {
        CGRect frame2 = CGRectMake(48, 12, 250, 50);
        UILabel *lbl2 = [[UILabel alloc] initWithFrame:frame2];
        lbl2.textAlignment = NSTextAlignmentLeft;
        [lbl2 setFont:[UIFont fontWithName:@"Helvetica" size:10.0]];
        [lbl2 setTextColor:[UIColor blueColor]];
        lbl2.text = [[stories objectAtIndex: storyIndex] objectForKey: @"owner_name"];
        [cell.contentView addSubview:lbl2];
        [lbl2 release];
    }

    return cell;
}
4

0 回答 0