0

I have a UIView inside a UIView, now when I click on button in the nested UIView, I want to refresh the full UIView.

How can I inform the parentView to refresh when a button is pressed?

When I press a button in nested View - view2 - I want to do this in the parent view - view1 userImage.hidden = true

When there is a button pressed in content view, I want to hide userImage from the view This content View is actually displaying another View Controller, in that view controller when a button is pressed, I want to update the view

EDIT - The solution I am thinking of is to reload the full View Controller. How can I reload the parentView Controller?

user2848975
  • 117
  • 1
  • 12

1 Answers1

-1

You can do so by using the - (void)setNeedsDisplay; method

[view setNeedsDisplay];
Karim H
  • 1,543
  • 10
  • 24
  • setNeedsDisplay is only recommended when you are using drawRect as mentioned [here](http://stackoverflow.com/questions/10818319/when-do-i-need-to-call-setneedsdisplay-in-ios) – Byte Sep 07 '16 at 05:13
  • try **- (void)setNeedsLayout;** – Karim H Sep 07 '16 at 05:15
  • When I refer the parent view from nested view, it gives, parent view as nil – user2848975 Sep 07 '16 at 05:33
  • Then it's not nested. If you added it as a subview it's supervise is not nil. – HAS Sep 07 '16 at 05:35
  • please see the new image added – user2848975 Sep 07 '16 at 05:47
  • Your screen shot does not show the button. In the action method of your button do a `sender.superview?.superview?.setNeedsLayout()` and `sender.superview?.superview?.layoutIfNeeded()` if you want it to happen immediately. – HAS Sep 07 '16 at 06:06
  • The button is present in the viewController, which is called in the contentView. That is why button is not in the screenshot – user2848975 Sep 07 '16 at 06:08