【问题标题】:How do I create a UITableView with UIImages? - Cocoa/Objective-C如何使用 UIImages 创建 UITableView? - 可可/Objective-C
【发布时间】:2009-02-23 22:46:45
【问题描述】:

我正在尝试使用类别表为 iPhone 创建一个应用程序。如果我选择一个类别,它将显示一个 UIImage。但是,我一直在研究它,但我不确定该怎么做。有人可以帮忙吗?

【问题讨论】:

    标签: iphone cocoa-touch uitableview


    【解决方案1】:

    听起来最简单的解决方案是在基于导航的应用程序中使用 UITableView。 (Apple 有关于如何使用它的示例)

    用您的类别加载表格。

    当用户选择一个类别时,将一个新视图从 Nib 文件推送到导航堆栈。

    这将允许您对所有类别使用相同的 Nib,并且您只需将要加载的图像传递给类,该类会处理将其加载到 UIImageView 中。

    例如:

    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {
    [tableView deselectRowAtIndexPath:indexPath animated:NO];
    
    imageCatView *catView = [[imageCatView alloc] initWithNibName: @"imageCatView" bundle: nil];
    catView.categoryID = [[[categories objectAtIndex: _selectedRow] objectForKey:@"CatID"] intValue];
    
    [[self navigationController] pushViewController:catView animated:YES];
    [catView release];
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-01-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-21
      • 1970-01-01
      • 2016-10-16
      相关资源
      最近更新 更多