0

我正在尝试使用类别表为 iPhone 创建一个应用程序。如果我选择一个类别,它将显示一个 UIImage。但是,我一直在研究它,但我不确定该怎么做。任何人都可以伸出援助之手吗?

4

1 回答 1

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];
}
于 2009-02-24T00:05:05.643 回答