4

I am using a uitableView in my application and I want to prevent reloading it in different cases: 1. when I present another modal view on it. 2. row selection happens.

I am not calling [tableview reloadData] in viewWillAppear or viewDidAppear. Is there anyway to prevent this reloading?

Leo
  • 24,596
  • 11
  • 71
  • 92
Niloufar
  • 512
  • 1
  • 5
  • 24
  • Make sure viewDidLoad not get called when you come back on table view. – Kumar Jul 11 '15 at 07:36
  • Your approach looks faulty to me. What are you trying to achieve? – user623396 Jul 11 '15 at 07:38
  • @DharmeshDhorajiya I'm trying to prevent reloading! – Niloufar Jul 11 '15 at 07:50
  • 1
    @LalitKumar I'm sure it's not being called! – Niloufar Jul 11 '15 at 07:50
  • @user623396 when a row selection happens the table is reloading I don't want the table to reload as I'm changing it's position using pan gesture when a selection happens it reloads and go back to it's original place. I want to prevent this reloading – Niloufar Jul 11 '15 at 07:51
  • The cell selection doesn't trigger table reload. It must be something else in your code. Try using `scrollRectToVisible:` to do your positioning. – user623396 Jul 11 '15 at 08:02
  • @user623396 I am using set frame in my gesture handler to change the position and height of tableview... – Niloufar Jul 11 '15 at 08:08
  • @Niloufar Something in there is causing the reload. If you can't prevent it at least you can reposition the table using scrollRectToVisible: after setting the frame. – user623396 Jul 11 '15 at 08:14
  • @user623396 thanks but I don't want the table to reload at all, I mean if it's maximized I want it to stay there. The point is not the selected row I want the whole table to be in the same position after selection or after presenting another view – Niloufar Jul 11 '15 at 08:19
  • @Niloufar Then I guess you need to post more of your code to see where the problem is. – user623396 Jul 11 '15 at 08:26

3 Answers3

3

Here is a way you can "track" where function calls come from:

example

  1. Add a breakpoint on the function header of the table view's datasource
  2. Then run your application with the debugger open and when the breakpoint points to your function header, click to the right of the Thread 1 and you will see how this breakpoint was called/reached

I hope this helps you and hope it was something called by you, the programmer because as you can see in my example, there was only one step that was done by me. How i can tell was the blue person icon next to 6 -[ViewController viewDidLoad]

ErickES7
  • 558
  • 6
  • 16
1
  • (void)reloadData; // reloads everything from scratch. redisplays visible rows. because we only keep info about visible rows, this is cheap. will adjust offset if table shrinks
    maybe can do it in change DataSource
bigCat
  • 11
  • 4
0

Thanks for your replies. There is no reload calling that causes this issue. I was using auto layout and the constraints set on tableview causes it to reload and change position when other view appears. Solution: When you do a selection os presentation use this command to prevent it from setting position for constraints:

tableView.translatesAutoresizingMaskIntoConstraints = YES;
Niloufar
  • 512
  • 1
  • 5
  • 24
  • i dont know how it works. can any one explain how this prevent the reloading of tableview? – Pushp May 23 '19 at 12:55