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
Post a Comment