iphone - 向 UITableView 添加详细信息 View

标签 iphone ios uitableview uiviewcontroller

这个应用程序是我的第一个使用 UITableView 的应用程序,我遇到了为什么尝试向其添加详细 View 的问题。 (因为我在第一次创建应用程序时将其设置为“基于 View 的应用程序”,所以我必须手动执行此操作)。

这是我的 TableView 的 didSelectRowAtIndexPath: 的代码:

detail = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle: [NSBundle mainBundle]];
detail.delegate = self;
detail.dtitle = [titles objectAtIndex: indexPath.row];
detail.dusername = [usernames objectAtIndex: indexPath.row];
detail.dpassword = [passwords objectAtIndex: indexPath.row];

[self.navigationController pushViewController: detail animated:YES];
//[self presentViewController:detail animated:NO completion:nil];

倒数第二行是导致问题的行。我从我制作的空白“主从应用程序”中复制了它,但它在这个应用程序中似乎不像在另一个应用程序中那样工作。注释掉的行是我一直在该位置使用的行,但并不完全是我想要的。

我可以做什么来解决这个问题?


其次,在DetailViewController中,我的标题栏(准确地说是导航栏的导航项)中的后退按钮不会出现。我是否需要添加代码来指示该 View 是从属 View 或其他 View ?

最佳答案

为了使用导航 Controller 推送另一个 View Controller ,实际上需要有一个导航 Controller 。 “self”在导航 Controller 中吗?

如果没有,则创建一个导航 Controller ,将其 Root View Controller 设置为第一个 View Controller 。如果第一个 View Controller 是应用程序的 Root View Controller ,现在将导航 Controller 设为 Root View Controller 。

一旦就位,您可以调用[self.navigationController PushViewController:detailanimate:YES];

关于iphone - 向 UITableView 添加详细信息 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18007681/

相关文章:

iphone - 在 iphone 中查找上次更新 sqlite 的日期

c++ - Cocos2dx 如何在没有 Schedule Selector 的情况下每 5 秒调用一个函数?

iOS >> UITableView 具有 2 个不同高度的自定义 UITableViewCell

ios - VKVideoplayer 在 Swift 中的使用

iphone - 如何在我的 iOS 应用程序中链接到网站或 Safari

iphone - iPhone 的非 Objective-C 编程状态如何?

ios - MFMessageComposeViewController 在发送消息 ios9 后不返回应用程序

ios - 如何使用 WKScriptMessageHandler 捕获发送到父元素的 postmessage?

ios - 无法使用 tableview cell.accessoryView 进行 Click 事件

ios - 异步查询后 UITableViewController 消失