0

课程:

  • 应用委托
  • 应用视图控制器
  • 其他视图控制器

当前,应用程序在 AppViewController 中打开。我想添加一个新视图,OtherViewController。但是我希望 AppViewController 中的方法保存到 OtherViewController 可以用来显示信息的 MutableArray。

1- 我应该在 AppDelegate 的哪里创建 MutableArray?然后我如何访问它?

我希望能够在 AppViewController 上滑动对象以使 OtherViewController 滑动,我只需使用 OtherViewController 上的后退按钮即可返回。

2-如何在控制器之间切换?

谢谢您的帮助!

4

1 回答 1

0

在 otherViewController 中创建一个 NSMutableArray(比如 otherArray)...不要忘记为该 Array 设置属性。因为它用作该 Object 的 getter 和 setter。在我们的例子中,我们需要设置该 Array 对象的值。

当您从 AppViewController 移动时,您会将视图控制器呈现为..

        OtherViewController *obj=[[OtherViewController alloc] initWithNibName:@"OtherViewController" bundle:nil];
            //Here
        obj.otherArray = yourArrayInAppViewController;
        [self presentModalViewController:obj animated:YES];
        [obj release];

只需 NSLog otherArray 计数在您的 OtherViewController 的 ViewDidLoad 中。您可以看到数组已通过...

于 2011-02-01T17:50:06.543 回答