Reputation: 2331
I have a "gallery of images" UIViewController with a UIScrollView for holding the images. From a child UIViewController the user can delete an image.
So, naturally when the user pops back to the gallery UIViewController, I would like to refresh its content so it will reflect the new situation.
However, the UIScrollView looks empty. Only when the user starts to scroll it, it refreshes and display the correct content.
In short: How can I programmatically refresh UIScrollView content?
note: setNeedDisplay did not help.
Upvotes: 1
Views: 130
Reputation: 2331
turn out it was a stupid bug.
i did wrong calculation for [scroller setContentOffset:..]. and gave it a value higher than the the UIScrollView contentSize.
when called scroller [setContentOffset:..] within the UIViewController, somehow, something fix it for me and set the value to be UIScrollView contentSize. but when called from another UIViewController it did not fix it for me, and so i "jumped beyond UIScrollView content".
Upvotes: 0
Reputation: 5812
simple way : what ever you do to create your gallery of images, do it in the viewWillAppear/viewDidAppear method of your view controller. but that'll be a lot of unnecessary work for your view controller to do
better would be to create a delegate, and call it when you delete an image. the delegate would again create the gallery of images.
Upvotes: 1