iphone - 如何分别创建UITableView和detail view

标签 iphone ios xcode uitableview ios5

我使用基于单一 View 创建了一个应用程序。现在我必须显示 15 个菜单和每个菜单的描述。所以我想到使用 UITableView 插入其中。同时选择一个单元格它应该显示长文本和图像内容。我是否必须为每个描述或任何快捷方式创建每个 ViewController 以编程方式添加描述 这是我的表格 View 代码

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

static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}

// Set up the cell...
cell.textLabel.font = [UIFont fontWithName:@"Helvetica" size:15];
cell.textLabel.text = [NSString  stringWithFormat:@"Cell Row #%d", [indexPath row]];

return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// open a alert with an OK and cancel button
NSString *alertString = [NSString stringWithFormat:@"Clicked on row #%d", [indexPath row]];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:alertString message:@"" delegate:self cancelButtonTitle:@"Done" otherButtonTitles:nil];
[alert show];
[alert release];
}

这是为了在单元格被触摸时创建 UIAlertView

如何显示长文本和图像。有什么想法吗。

最佳答案

我认为您可以使用导航 Controller 并在其上推送 tableView。在选择表格单元格时,您应该推送一个 detailView(所有单元格的一个详细 View )。仅当您必须在 detailView 中显示相同格式的详细信息数据时,这才有效。否则,如果您必须为每个选择使用不同的屏幕,那么您可以设计所有这些屏幕,这也会使其变得很重。

关于iphone - 如何分别创建UITableView和detail view,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11446324/

相关文章:

ios - 当 segmentedControl 改变时在单元格之间切换

iphone - iPhone OS 3.0.1 会毁掉你的开发手机吗?

ios - 存在 tabBar 时出现奇怪的定位问题

ios - AGX : Texture read/write assertion failed: height > 0

ios - 如何以编程方式检测 iPhone 中的 EDGE 网络或不良网络?

ios - 我可以从这个错误日志中推断出什么?

iphone - iOS 应用程序版本控制

ios - swift 将搜索栏添加到导航栏

xcode - 如何防止命令行工具在异步操作完成之前退出

iphone - objective-c : Do I have to retype all the code everytime?