【问题标题】:SWRevealViewController from one controller to anotherSWRevealViewController 从一个控制器到另一个
【发布时间】:2014-07-23 15:52:24
【问题描述】:

我正在与SWRevealViewController 合作,以便在应用程序上有一个侧边菜单。它从侧面菜单到控制器按预期工作。我现在想做的是再次从一个控制器到另一个控制器使用SWRevealViewController(两者都是UITableViewController)。

从侧边菜单到控制器 1 到控制器 2:

这是我迄今为止尝试做的:

使用 identifier "articlesSegue" 将 Interface Builder 中的 Real View Controller Segue 设置到第二个控制器。

在第一个控制器中,我使用didSelectRowAtIndexPathprepareForSegue 来显示第二个控制器:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Set selected issue to var
    _selectedIssue = _feedItems[indexPath.row];

    // Manually call segue to detail view controller
    [self performSegueWithIdentifier:@"articlesSegue" sender:self];
}

#pragma mark Segue

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Get reference to the destination view controller
    TableViewController *tableVC = segue.destinationViewController;

    // data used in the second Controller
    tableVC.self.type = @"category";
    tableVC.self.data = [_selectedIssue.ID stringValue];
}

从列表中选择一个项目显示为已选择,但没有任何反应。

我已经使用 Push Segue 对其进行了测试,它确实有效,但我仍然更喜欢它而不是使用 SWRevealViewController

我确实找到了这个问题,但我不太确定它必须如何实施,SWRevealViewController - manually switch to another view?

【问题讨论】:

  • 你需要什么结果,你想从侧面菜单到主VC或主VC到另一个VC,你能显示你的屏幕截图
  • @Anbu.Karthik 截图添加到问题

标签: ios objective-c swrevealviewcontroller


【解决方案1】:

正如@Anbu.Kathik 解释的那样,我无法使用SWRevealController 移动到另一个Controller。我已经通过使用相同的TableViewController 解决了这个问题,我添加了一个属性type 来检查哪个是当前的“tableview”,并在didSelectRowAtIndexPath 上选择一个项目时简单地更新表格。

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    // check type of current tableview - if category display article
    if ([self.type isEqualToString:@"category"]) {
        // display single article
        _selectedArticle = _feedItems[indexPath.row];
        [self performSegueWithIdentifier:@"detailSegue" sender:self];
    }
    else {
        // else if issue display list of articles on the same TableViewController
        _selectedIssue = _feedItems[indexPath.row];
        self.type = @"category";
        self.data = [_selectedIssue.ID stringValue];
        [_homeModel downloadItems:self.type :self.data];
    }
}

使用[self.tableView reloadData] 使用新数据重新加载表。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-06-28
    • 2013-05-21
    • 1970-01-01
    • 2019-11-15
    • 1970-01-01
    • 1970-01-01
    • 2015-09-07
    相关资源
    最近更新 更多