【问题标题】:JTRevealSidebar push to ViewControllerJTRevealSidebar 推送到 ViewController
【发布时间】:2013-03-12 20:14:26
【问题描述】:

我正在使用 JTRevealSidebar V2,左侧滑动条上带有 UITableView

我不知道如何通过发送消息来推送到其他 ViewController。

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (self.sidebarDelegate) {
       NSString *text = [self.leftList objectAtIndex:indexPath.row];
        if ([text isEqual:@"Warenkorb"]) {
            NSLog(@"Ist warenkorb");
           // How to push/create/bring2top view of msCartViewController Identified by "Cart"?
           // NSLog works
        }
    }
}

如何做到这一点?

【问题讨论】:

    标签: iphone ios xcode ios6


    【解决方案1】:

    在您的 rootviewcontroller 中,您将分配一个新的 UIViewController,然后将其推送到 UINavigation 堆栈中。

    例如:

    UIViewController *myViewController = [[UIViewController alloc] init];

    myViewController.title = @"我的第一个视图";

    myViewController.view.backgroundColor = [UIColor redColor];

    //推送UIView。

    [self.navigationController pushViewController:myViewController 动画:YES];

    请记住在您的根视图控制器中执行此操作! 希望这会有所帮助。

    【讨论】:

      【解决方案2】:

      也许,您的问题是如何从情节提要中获取实例,因为我看到您在情节提要中将您的 msCartViewController 称为“Cart”。

      或者也许您无法让导航控制器进行推送。

      第一个问题

      UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle: nil];
      msCartViewController* vc=[storyboard instantiateViewControllerWithIdentifier:@"Cart"];
      

      对于第二个问题,您需要将导航控制器指针存储到您可以访问的某个位置,例如在单例中的字典属性中。就像

      // at first make a singleton with a dictionary property. here I call it YourNavigationCenter
      
      UINavigationController *navigationController = [YourNavigationCenter sharedCenter].navigationDictionary[@"yourNavigationName"];
      [navigationController pushViewController:self animated:YES];
      

      如果这些解决方案没有抓住你的意思,请发表评论。

      【讨论】:

        猜你喜欢
        • 2012-02-08
        • 1970-01-01
        • 2013-12-18
        • 1970-01-01
        • 2014-10-13
        • 1970-01-01
        • 2019-02-21
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多