TableView changes frame when I view ScrollView

I have this specific problem, simple but very pathetic. Trying this from yesterday, please give me some solution for this.

1) I have a view with ScrollView.

2) I have two UIView and Two TableView on it.

3) What I want is a view that needs to expand and contract.

4) So, I took two views, because I can not hide part of the UIView.

5) What I did was hide the second view by default through XIB and click on the button that is on FirstView, I will show the second view, which I placed just below FirstView

6) Now, Since I have Two TableView, which should be displayed under the first view and must change their frame to appear under subView (SecondView) when subView (SecondView) is not hidden.

7) What I did was that I placed the first table below the first view and above the hidden view (SecondView) and the second table below the first table.

8) Thus, when I click the button on the first view, I hide this button and hide the SecondView and change the tableVC frame so that it appears under the second view.

9) Similarly, when I click a button on the second screen, I hide this button and I hide the SecondView and display the button in the first view and change the frame of the VV table so that it appears below the first view, i.e. starting position.

Perhaps these screen shots may be useful.

enter image description here

The gray part is the first table, and the pink part is the second table.

enter image description here

Green Portion is an extended view that was hidden, and tableVC (gray) was on top of it.

Now everything was very good, when I came across this, when I scroll, the table view changes its frame randomly. When I expand the firstView and scroll the table, its frame changes and moves up. Similarly, when I swear and scroll, the same thing happens.

Here is a screenshot (Image while I scroll).

enter image description here

Here is my code:

-(IBAction)expand:(id)sender{ if (addButton){ [addButton setHidden:YES]; [subView setHidden:NO]; [objTableViewForServices setFrame:CGRectMake(7, 310, 306, 136)]; [objTableViewForManagement setFrame:CGRectMake(7, 480, 306, 136)]; objScrollView.contentSize = CGSizeMake(320,700); } } -(IBAction)collapse:(id)sender{ if (subButton){ [subView setHidden:YES]; [addButton setHidden:NO]; [objTableViewForServices setFrame:CGRectMake(7, 229, 306, 136)]; [objTableViewForManagement setFrame:CGRectMake(7, 396, 306, 136)]; objScrollView.contentSize = CGSizeMake(320,650); } } 

Probably a scrolling issue.

Please help me as soon as possible since I need to finish this on time.

Thanks. Regards.

+4
source share
1 answer

ITO due to auto detection and limitation. There are two solutions:

1) Delete scrollview car property

2) If you want autorun, use the correct restriction

0
source

Source: https://habr.com/ru/post/1493582/


All Articles