1

I'm using Xcode 4.6 to build an iOS 6.x tabbar application and using Storyboard's. Inside each tabbed view, there is no problem adding a UIScrollView and interacting with any of the elements that are placed therein.

However... when I tap a button to transition to a new view in my storyboard using a Modal Segue, the scroll view doesn't work in the modal view.

Example:

Both TestViewController.h and TRViewController.h contain code similar to this:

@property (strong, nonatomic) IBOutlet UIScrollView *scroller;

In the viewDidLoad method on in both TestViewController.m and TRViewController.m:

[_scroller setScrollEnabled:YES];
[_scroller setContentSize:CGSizeMake(320, 1000)];

Then in IB, the outlet is hooked up properly to the view:

enter image description here

So my code is replicated / the same across IB, .h, and .m for each of the views. Works in one area, but not the other. Beyond that, the only other block of what I think might be relevant to my problem might be from the segue:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    if ([segue.identifier isEqualToString:@"trSegue"]) {        
    TRViewController *_trVC = segue.destinationViewController;
    _trVC.delegate = self;
    }
}

Am I just missing something so totally obvious? I'm thinking it's going to be a palm to forward moment once I see the solution...

Thoughts / comments?

Thanks in advance! - Drew

4

2 回答 2

1

我想到了。你必须把你的 UIScrollView 放在另一个空的 UIView 中。您的层次结构在界面构建器中将如下所示:

在此处输入图像描述

原因在于模态转场显示您的内容的方式。当你执行 push segue 时,它​​实际上将 ViewController 推送到导航堆栈的最顶层,而使用模态 segue 它会更改屏幕上显示的内容。我不确定这是否会导致苹果拒绝您的应用程序,但它可以工作。

于 2013-07-15T20:41:02.947 回答
0

好吧...我发现如果我只是将 segue 从 Modal 更改为 Push ...它可以很好地工作而无需任何额外的调整/调整。我想我会走这条路,而不是再胡思乱想。

也就是说,我仍然很想找到一种方法来做到这一点(如果可能的话)。

于 2013-02-22T02:12:59.353 回答