从 UIPopoverController 内的 UITableView 中的行推送 viewController
所以我的 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
听起来像 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.