swift - Table rows in segmented control wont scroll up when segment changes -


i have 2 segments onc , ofc, after data displayed in onc segment , scroll row15, when change segment ofc, shows row15 want show row1

public func tableview(_ tableview: uitableview, numberofrowsinsection section: int) -> int {     var typeofevent = 0     switch (eventsegctrl.selectedsegmentindex)     {     case 0:         typeofevent = oncevents.count         break     case 1:         typeofevent = ofcevents.count         break     default:break     }      return typeofevent } 

how solve this?

the simplest solution on reload of tableview can set contentoffset cgpoint.zero.

self.tableview.setcontentoffset(cgpoint.zero, animated: false) 

Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -