NevzatR
NevzatR

Reputation: 245

Scroll always start on the top in ScrollView?

I have an UITableView and all rows navigate to other UIView which include UIScrollView. Sometimes when I navigate it scroll start middle of the view, or bottom of the view. But I want everytime I scroll it, scroll must be on the top of the view. How can i do that?

Upvotes: 3

Views: 1977

Answers (3)

iPhone Guy
iPhone Guy

Reputation: 1046

make sure you are using [self.scrViewHaberDetay setContentOffset:CGPointMake(0, 0)]; in viewWillAppear or viewDidAppear, not in the viewDidLoad. It will then work.

Upvotes: 4

JohnZ
JohnZ

Reputation: 14

I think when the UIView loaded, you can manually make it scroll to top, so it will always be start on top. [self.scroll scrollRectToVisible:rc animated:YES], rc is CGRect, you can make it rc.origin.x=0, rc.origin.y=0;

Upvotes: 0

klefevre
klefevre

Reputation: 8735

Use this methods : [_tableView setContentOffset:CGPointMake(0.f, 0.f) animated:NO];

Upvotes: 0

Related Questions