模态segue需要2次点击而不是一次 [英] Modal segue needs 2 clicks instead of one

查看:107
本文介绍了模态segue需要2次点击而不是一次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的UITableView需要2次点击才能显示所选单元格的详细信息页面:一个用于选择,另一个用于显示详细信息视图。我想要一个clic直接显示点击单元格的详细视图。

My UITableView needs 2 clicks to show the detail page of the selected cell : one for selection and another one for show the detail view. I would like one clic to directly show the detail view of the clicked cell.

我在UITableViewManager.m中使用了一个模态segue:

I use a modal segue with this method inside my UITableViewManager.m :

    - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([[segue identifier] isEqualToString:@"showDetail"]) {
        NSIndexPath *indexPath = [playerList indexPathForSelectedRow];
        TCPlayerStat *object = _objects[indexPath.row];
        [[segue destinationViewController] setPlayerStat:object];
    }
}

我无法使用push segue,因为我没有导航控制器(并不是真的想要)。

I can't work with a push segue because I don't have Navigation Controller (and don't really want to).

我查看了TableView属性检查器,但没有找到与此相关的任何内容。我选择了单选选项并选中显示选择触摸。
我不知道这是否可行,如果可能,在哪里看..

I've looked in the TableView Attribute Inspector but didnt find out anything relevant for this. I have Selection "Single Selection" selected and "Show Selection on Touch" checked. I don't know if this is possible and if it is, where to look..

感谢您的帮助。

编辑1:当我写这样的两种方法时,它仍然不起作用(需要2次点击)并且我有一个新的警告日志:

EDIT 1: When I write the two methods like this, it still doesn't work (needs 2 clicks) and I have a new warning log:


警告:在演示文稿正在进行时,尝试在
TCRootViewController:0xa24f050上显示TCDetailViewController:0xa27b900!

"Warning: Attempt to present TCDetailViewController: 0xa27b900 on TCRootViewController: 0xa24f050 while a presentation is in progress!"



- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [self performSegueWithIdentifier:@"showDetail" sender:self];
}

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([[segue identifier] isEqualToString:@"showDetail"]) {
        NSIndexPath *indexPath = [playerList indexPathForSelectedRow];
        TCPlayerStat *object = _objects[indexPath.row];
        TCDetailViewController *detailViewController = [segue destinationViewController];
        [detailViewController setPlayerStat:object];
    }
}






编辑2:我不知道为什么,但有时它完美无缺,不需要再次点击表视图。找不到:/


EDIT 2: I don't know why, but sometimes it works perfectly and doesn't need a second click on the table view. Can't find out :/

以下解决方案

推荐答案

我喜欢这个问题!

我在故事板上更改了一个我不应该参数的参数没有。我希望选择单元格在单击时不显示背景高亮颜色,但看起来Segue基于它可以正常工作。

I changed a parameter on the Storyboard that I shouldn't have. I wanted the selection cell not to display a background highlight color when I click on it, but it seems the Segue is based on it to work decently.

如何要修复:
在故事板中,在导航器中选择表视图单元格,不要在选择(属性检查器)中选择无选项。 蓝色,灰色或默认似乎效果很好。

这篇关于模态segue需要2次点击而不是一次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆