从 UIPopoverController 内的 UITableView 中的行推送 viewController

发布于 2024-10-31 14:46:57 字数 1477 浏览 3 评论 0原文

所以我的 iPad 应用程序中有一个 viewcontroller。它有一个 UIPopoverViewController,里面有一个 UITableView。我希望用户能够在 tableView 中选择一行,然后 rootViewController 将关闭弹出窗口并推送一个新的 viewController。提前致谢。

这是我到目前为止所尝试过的:

在 UITableView 类中:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
WelcomeViewController *welcomeView = [[WelcomeViewController alloc] init];
welcomeView.whichDay = [daysOfTheWeek objectAtIndex:indexPath.row];
[welcomeView pushFromPopOver];

}

然后在 rootViewController 中:

-(void)pushFromPopOver{
  //PlannerPage *plannerPageViewController = [[[PlannerPage alloc] initWithNibName:@"PlannerPageiPad" bundle:nil] retain];

    [popover dismissPopoverAnimated:YES];
    [popover.delegate popoverControllerDidDismissPopover:popover];
    NSLog(@"%@",whichDay);

    PlannerPage *plannerPageViewController = [[[PlannerPage alloc] initWithNibName:@"PlannerPageiPad" bundle:nil] retain];
    plannerPageViewController.dayOfTheWeekString = whichDay;
    [self.navigationController pushViewController:plannerPageViewController animated:YES];

    //plannerPageViewController.dayOfTheWeekString = @"";
    //[self.navigationController pushViewController:plannerPageViewController animated:YES];
    //[plannerPageViewController release];
  }

NSLog 告诉我选择了什么,但弹出窗口不会关闭,并且 rootViewController 不会推送

我虽然可能使用委托,但我不知道怎么办。 提前致谢。

So I have a viewcontroller in my iPad app. It has a UIPopoverViewController with a UITableView inside it. I want the user to be able to select a row in the tableView and then the rootViewController will dismiss the popover and push a new viewController. Thanks in advance.

This is what I've tried so far:

In the UITableView class:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
WelcomeViewController *welcomeView = [[WelcomeViewController alloc] init];
welcomeView.whichDay = [daysOfTheWeek objectAtIndex:indexPath.row];
[welcomeView pushFromPopOver];

}

Then in the rootViewController:

-(void)pushFromPopOver{
  //PlannerPage *plannerPageViewController = [[[PlannerPage alloc] initWithNibName:@"PlannerPageiPad" bundle:nil] retain];

    [popover dismissPopoverAnimated:YES];
    [popover.delegate popoverControllerDidDismissPopover:popover];
    NSLog(@"%@",whichDay);

    PlannerPage *plannerPageViewController = [[[PlannerPage alloc] initWithNibName:@"PlannerPageiPad" bundle:nil] retain];
    plannerPageViewController.dayOfTheWeekString = whichDay;
    [self.navigationController pushViewController:plannerPageViewController animated:YES];

    //plannerPageViewController.dayOfTheWeekString = @"";
    //[self.navigationController pushViewController:plannerPageViewController animated:YES];
    //[plannerPageViewController release];
  }

The NSLog is telling me what was selected, but the popover will not dismiss and the rootViewController will not push

I though maybe use a delegate but I'm not sure how.
Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

公布 2024-11-07 14:46:57

听起来像 NSNotificationCenter 它非常适合您的需求。您的根视图控制器应该侦听 NSNotification,并且您的弹出窗口应该发布该通知。

Sounds like NSNotificationCenter it perfect for what you need. Your root view controller should listen for an NSNotification and your popover should post that notification.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文