(別のビューコントローラの)前のビューに戻るボタンがありますが、そのビューの最後のビューに戻ることができます。私はいつもそのビューの一番上に戻りたいのですが、どうやって?
3 に答える
2
以前の ViewController で、viewWillAppear メソッドをオーバーライド/実装します。
- (void)viewWillAppear:(BOOL)animated{
// you may change the position of the scrollview or you may re initialize desired views
}
于 2012-08-21T07:53:38.600 に答える
1
if your previous view is inherited from UIScrollView
you should add that code for your specific view, I've included all main type of views, I'm not sure you will need all of it, but
I don't know which one is your previous view, so you can choose the proper one.
- (void)viewWillAppear:(BOOL)animated {
[scrollView setContentOffset:CGPointZero];
[tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:false];
[textView scrollRangeToVisible:NSMakeRange(0, 1)];
}
于 2012-08-21T08:34:04.637 に答える