scrollView always go back to the starting position after closing subview
up vote
0
down vote
favorite
My application has the main view and multiple subviews. What I want to do is: when View2?.removeFromSuperview()
then scrollView would start from the beginning. Because now I put subviews ON the main view and then when I go back to main view, scrollview is at the same position as it was before.
ios swift
add a comment |
up vote
0
down vote
favorite
My application has the main view and multiple subviews. What I want to do is: when View2?.removeFromSuperview()
then scrollView would start from the beginning. Because now I put subviews ON the main view and then when I go back to main view, scrollview is at the same position as it was before.
ios swift
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
My application has the main view and multiple subviews. What I want to do is: when View2?.removeFromSuperview()
then scrollView would start from the beginning. Because now I put subviews ON the main view and then when I go back to main view, scrollview is at the same position as it was before.
ios swift
My application has the main view and multiple subviews. What I want to do is: when View2?.removeFromSuperview()
then scrollView would start from the beginning. Because now I put subviews ON the main view and then when I go back to main view, scrollview is at the same position as it was before.
ios swift
ios swift
asked Nov 8 at 22:08
SwiftyLifestyle
396
396
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
offset = CGPoint(x: -yourScrollView.adjustedContentInset.left,y: -yourScrollView.adjustedContentInset.top)
yourScrollView.setContentOffset(offset, animated: true)
try this
Works like a charm! Thank you so much.
– SwiftyLifestyle
Nov 8 at 23:10
you welcome. But I think this kind of questions already exist; so from next time you should try to find already existing ones. So you won't get down vote ;)
– Hikaru Watanabe
Nov 8 at 23:17
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
offset = CGPoint(x: -yourScrollView.adjustedContentInset.left,y: -yourScrollView.adjustedContentInset.top)
yourScrollView.setContentOffset(offset, animated: true)
try this
Works like a charm! Thank you so much.
– SwiftyLifestyle
Nov 8 at 23:10
you welcome. But I think this kind of questions already exist; so from next time you should try to find already existing ones. So you won't get down vote ;)
– Hikaru Watanabe
Nov 8 at 23:17
add a comment |
up vote
0
down vote
accepted
offset = CGPoint(x: -yourScrollView.adjustedContentInset.left,y: -yourScrollView.adjustedContentInset.top)
yourScrollView.setContentOffset(offset, animated: true)
try this
Works like a charm! Thank you so much.
– SwiftyLifestyle
Nov 8 at 23:10
you welcome. But I think this kind of questions already exist; so from next time you should try to find already existing ones. So you won't get down vote ;)
– Hikaru Watanabe
Nov 8 at 23:17
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
offset = CGPoint(x: -yourScrollView.adjustedContentInset.left,y: -yourScrollView.adjustedContentInset.top)
yourScrollView.setContentOffset(offset, animated: true)
try this
offset = CGPoint(x: -yourScrollView.adjustedContentInset.left,y: -yourScrollView.adjustedContentInset.top)
yourScrollView.setContentOffset(offset, animated: true)
try this
answered Nov 8 at 22:23
Hikaru Watanabe
12211
12211
Works like a charm! Thank you so much.
– SwiftyLifestyle
Nov 8 at 23:10
you welcome. But I think this kind of questions already exist; so from next time you should try to find already existing ones. So you won't get down vote ;)
– Hikaru Watanabe
Nov 8 at 23:17
add a comment |
Works like a charm! Thank you so much.
– SwiftyLifestyle
Nov 8 at 23:10
you welcome. But I think this kind of questions already exist; so from next time you should try to find already existing ones. So you won't get down vote ;)
– Hikaru Watanabe
Nov 8 at 23:17
Works like a charm! Thank you so much.
– SwiftyLifestyle
Nov 8 at 23:10
Works like a charm! Thank you so much.
– SwiftyLifestyle
Nov 8 at 23:10
you welcome. But I think this kind of questions already exist; so from next time you should try to find already existing ones. So you won't get down vote ;)
– Hikaru Watanabe
Nov 8 at 23:17
you welcome. But I think this kind of questions already exist; so from next time you should try to find already existing ones. So you won't get down vote ;)
– Hikaru Watanabe
Nov 8 at 23:17
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53216896%2fscrollview-always-go-back-to-the-starting-position-after-closing-subview%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown