mluton / EmbeddedSwapping

Demonstration of how to make a custom container view controller manage multiple child view controllers using storyboards.
MIT License
208 stars 30 forks source link

Scroll issue inside any view #5

Closed felipeflorencio closed 11 years ago

felipeflorencio commented 11 years ago

Hello, there a issue when we insert into a view any scroll view element, like text scroll view, the scroll just dont work, do u know any way to resolve this issue i really need a solution

mluton commented 11 years ago

This is an interesting one. The two key properties to set on the scroll view are scrollEnabled and userInteractionEnabled. Both should be set to YES. However, it turns out that's not quite enough. The userInteractionEnabled property also has to be set to YES on the container view.

I added a UITextView to the storyboard for the second view controller with lengthy default text. Then I did self.view.userInteractionEnabled = YES in viewDidLoad for the second view controller.

- (void)viewDidLoad
{
    [super viewDidLoad];
    NSLog(@"SecondViewController - viewDidLoad");

    // Make it so any subviews can respond to user interaction. For example,
    // scroll views responding to scroll events. It's not enough for the
    // subview to have userInteractionEnabled set to true. It needs be set in
    // the container view as well. --mluton (2013-06-24)
    self.view.userInteractionEnabled = YES;
}

Since this falls a bit outside the core example of simply swapping two view controllers I committed this to a new branch called scrolling and pushed it to the GitHub project.