Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
585 views
in Technique[技术] by (71.8m points)

iphone - Dismiss modal view changes underlying UIScrollView

There must be something basic that I am missing here. I have a UIScrollView open, which is controlled by a customer UIScrollViewController (called DataController). At a certain point in time, input from the user is needed, so I open a modal UIViewController from the DataController:

ElementSelectController *viewController = [[ElementSelectController alloc] initWithNibName:@"ElementSelectController" bundle:nil];
viewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
viewController.theDelegate = self;
[self presentModalViewController:viewController animated:YES];

Once the user is ready with the modal view, it is dismissed again. This also happens from the DataController:

[self dismissModalViewControllerAnimated:YES];

This all works fine. But when the modal view is gone, it turns out that the underlying UIScrollView is resized to full screen, and scrolled to position (0,0). This is the case even with a simple modal view that does not do anything else but be dismissed. Obviously, I want the UIScrollView to remain in the same state and size as it was before the modal view came up.

Any ideas what I am doing wrong?

I checked the stack trace when the UIScrollView frame is set (through a break-point in setFrame: of a custom UIScrollView), and it appears that it is called from:

-[UITransitionView transition:fromView:toView:]

which is called via, via from the dismissModalViewControllerAnimated call.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
-[UITransitionView transition:fromView:toView:]

Is perfectly normal for transitioning from the modal back to your view. This is the animation etc, try you modal with animation if you think that could make a difference.

Take a look at your viewWillAppear, WillDisappear, DidAppear... Even the Load and Unload if appropriate, although unlikely those are called for your trivial test with nothing in the modal. Try placing some logging in those methods to see which is called.

Also are you saying there is no custom code in those methods, or your controller doesn't override them at all? Could make a difference.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...