首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >presentModalViewController问题!

presentModalViewController问题!
EN

Stack Overflow用户
提问于 2011-06-08 15:37:57
回答 1查看 627关注 0票数 1

所以,

我有一个表单(基本上是一个UITableView),完成表单后,我单击屏幕上方的“完成”按钮。

单击后,我需要将数据添加到另一个tableView (在另一个tableViewController中)。此表还位于导航控制器内。

按下Done Button之后,我需要presentModalViewController成为新的tableView (带有新的数据)以及TableView之上的导航控制器。

所以,总结一下:

someTableViewController.

  • I中的Done Button需要在另一个名为dogTableViewController.

  • I重载数据的tableView中添加一个名为"Dobby“的对象(简单地说,我正在添加一个名为”Dobby“的名称),并显示dogNavigationController.

  • All中有dogTableViewController的屏幕,正确引用和包含类。

单击Done按钮时,我正在粘贴-(IBAction)。

代码语言:javascript
复制
-(IBAction) doneWithData: (UIBarButtonItem*) sender{


 UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
indicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge;
[indicator sizeToFit];
indicator.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin |
                              UIViewAutoresizingFlexibleRightMargin |
                              UIViewAutoresizingFlexibleTopMargin |
                              UIViewAutoresizingFlexibleBottomMargin);

indicator.tag = 1;
[self.view addSubview:indicator];
[indicator setBackgroundColor:[UIColor clearColor]];
indicator.center = self.view.center;
indicator.hidden = FALSE;
[indicator startAnimating];

if (self.dogTableViewController == nil)
{
    DogTableViewController *temp = [[DogTableViewController alloc] init];
    self.dogTableViewController = temp;
    [temp release];
}

if (self.dogNavigationController == nil)
{
    DogNavigationController *temp = [[DogNavigationController alloc] init];
    self.dogNavigationController = temp;
    [temp release];
}

[self.dogTableViewController.dogArray addObject:@"Dobby"];
[self.dogTableViewController.tableView reloadData];

NSLog (@"%@", [self.dogTableViewController.dogArray objectAtIndex:0]); 
//Prints out "Null" //

[self presentModalViewController:dogNavigationController animated:YES];


[indicator release];

}

当我这样做的时候,点击完成按钮,

我得到一个没有桌子的空导航屏幕。此外,我还在dogNavigationController屏幕上设置了一些按钮。什么都看不见!!

我的目标是将屏幕转移到这个新屏幕(碰巧是主屏幕,而不是rootController)。你认为我应该和modalViewController一起完成这个任务吗?你认为我应该用其他方式将数据传输到另一个屏幕吗?

附注:我不想使用PushViewController。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-06-08 15:51:19

我觉得你应该做

代码语言:javascript
复制
[self.navigationController popToRootViewControllerAnimated:YES];

更确切地说。要获得根视图控制器,可以这样做,

代码语言:javascript
复制
DogTableViewController * viewController = [self.navigationController.viewControllers objectAtIndex:0];
[viewController.dogArray addObject:aDog];

原始答案

您不应该用根视图控制器初始化导航控制器吗?

代码语言:javascript
复制
DogNavigationController *temp = [[DogNavigationController alloc] initWithRootViewController:self.dogTableViewController];
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6281451

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档