ios - UIScrollView disable scrolling when removeFromSuperView -
I have a .xib file that has a view, a tab bar and other 3 scrolls, when the user has a new tab Selects Bar Items I execute this code:
// View e scroll IBOutlet UIView * myView; IBotlate UIScroll view * MyScroll; IBotlet UICroll View * myScroll2; IBOutlet UIScrollView * myScroll3; @property (nanatomic) uiscrollview * scroll; - (blank) tabbar: (UITabBar *) Tabber selected: (UITabBarItem *) Item {NSArray * viewsToRemove = [MyView subviews]; (UIView * v in viewsToRemove) {[v removeFromSuperview]; } If (item.tag == 1) {self.title = @ "scroll 1"; Scroll = myScroll; } If (item.tag == 2) {self.title = @ "scroll 2"; Scroll = myScroll2; } If (item.tag == 3) {self.title = @ "scroll 3"; Scroll = myScroll3; } Scroll.contentSize = scroll.frame.size; Scroll.frame = myView.frame; Scroll.scrollEnabled = Yes; [MyView addSubview: scroll]; [MyView setBackgroundColor: [UIColor clear collar]]; } This code works great, but when I select a scroll which was previously deleted from the scene, then they lose their scrolls (which were not previously ), Why is this happening and how to solve it?
Here's the line:
Scroll to ContentSize = scroll .frame.size; When your UIScrollView s contentSize matches its frame size , then its requirement Not Scroll (By definition) You have to understand the actual size of its content and use it. You can display at least the right functionality by doing this (even if it is not with the right values):
scroll.contentSize = CGSizeMake (scroll.frame.size.width * 2, Scroll .frame.size.height * 2); You have to find the size of the original content for yourself, though.
Comments
Post a Comment