Search code examples
uiviewxcode4uiscrollview

Clear UIView / UIScrollView content upon dismissal of modal view


I currently have a UIView / UIScrollView that is displayed within a modal view. It is basically a detail view that provides a view of a page when the user clicks a link. When the view is dismissed and then brought up again (when the user clicks another button), the previously-loaded content is still visible and the new content loads "on top" of the last content. This makes sense because the instance of the UIView / UIScrollView persists and is only released when the memory is needed.

However, I would like to completely clear the UIView / UIScrollView when the modal view is dismissed so that 1) content is cleared and 2) memory is freed.


Solution

  • rightDetailedView = [[UIScrollView alloc] init]; rightDetailedView.backgroundColor = [UIColor whiteColor];

    The above code initializes the view every time this method is called and to my knowledge when we are recreating a view the background will be transparent so we need to add backgroundColor with whiteColr or some color.

    Thanks,

    Kris :)