我正在创建一个带有 UITableView
的应用程序作为 UINavigationController
堆栈中的第一项它在里面。在 UITableView
上进行选择会将 View 推送到“DetailedViewController
”。在DetailedViewController
,您可以浏览表格 View 填充的项目。
弹出 DetailedViewController
时,然后回到 UITableView
, 如何取消选择我通过 DetailedViewController
导航到的相应项目并将其显示在 UITableView
的中心?
每个人都可以看到的一个例子是邮件应用程序。当您在收件箱中进行选择时,您会按下“DetailedViewController
”。在那里,您可以浏览 UITableView
中填充的项目。 .当你弹出 DetailedViewController
, 它会取消选择您最后在 DetailedViewController
中查看的相应项目.
最佳答案
要取消选择所选行,请编写以下代码 viewDidAppear:
方法。
// Index path for selected row
NSIndexPath *selectedRow = [_tableView indexPathForSelectedRow];
// Deselet the row with animation
[_tableView deselectRowAtIndexPath:selectedRow animated:YES];
// Scroll the selected row to the center
[_tableView scrollToRowAtIndexPath:selectedRow
atScrollPosition:UITableViewScrollPositionMiddle
animated:YES];
关于ios - 将 UINavigationController 弹出到 UITableView 并显示不同的选定行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7343954/