【发布时间】:2009-02-23 22:46:45
【问题描述】:
我正在尝试使用类别表为 iPhone 创建一个应用程序。如果我选择一个类别,它将显示一个 UIImage。但是,我一直在研究它,但我不确定该怎么做。有人可以帮忙吗?
【问题讨论】:
标签: iphone cocoa-touch uitableview
我正在尝试使用类别表为 iPhone 创建一个应用程序。如果我选择一个类别,它将显示一个 UIImage。但是,我一直在研究它,但我不确定该怎么做。有人可以帮忙吗?
【问题讨论】:
标签: iphone cocoa-touch uitableview
听起来最简单的解决方案是在基于导航的应用程序中使用 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];
}
【讨论】: