【发布时间】:2013-11-04 15:14:03
【问题描述】:
我的应用程序有问题。 当我以这种方式将 UIView 传递给 SecondViewController 时
SecondViewController *second = [self.storyboard instantiateViewControllerWithIdentifier:@"secondviewcontroller"];
second.currentView = currentView;
(second.currentView 是我在 SecondViewController 中的属性,我将视图传递给它)
此时,一切正常,我的 SecondViewController 正确显示了我的 currentView,但是当我在 FirstViewController 中返回时,我的 currentView 消失了!!! 为什么?你能帮助我吗?谢谢
更新
在 FirstViewController.h 中
IBOutlet UIView *currentView;
在 FirstViewController.m 中
SecondViewController *second = [self.storyboard instantiateViewControllerWithIdentifier:@"secondviewcontroller"];
second.currentView = currentView;
[self presentViewController:second animated:NO completion:nil];
在 SecondViewController.h 中
@property (nonatomic, strong) UIView *currentView;
在 SecondViewController.m 中
- (void) viewDidAppear:(BOOL)animated{
[self.view addSubview:self.currentView];
self.currentView.center = CGPointMake(self.view.bounds.size.width/2, self.view.bounds.size.height/2);
}
这是我在两个 ViewController 中的代码,当我在 FirstViewController currentView 中返回时,没有……它消失了……
【问题讨论】:
-
是的,我更新了我的问题
-
是的,我使用dismissViewController
-
我认为最好的解决方案是在 appDelegate 中使用全局变量,这样我就解决了我所有的问题
-
我试过了,还是没有解决我的问题
-
这只是 [self dismissViewControllerAnimated:NO completion:nil];在 IBAction 内
标签: ios properties uiviewcontroller storyboard