Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing parent view of current view - iOS

When I want to access the parent UIView of current UIView I declare object of parent UIView in current UIView and access it by assigning the parent UIView object to current view's object property.

Is there any way to get rid of this and directly call the parent view's methods or properties?

I also tried (parentView *) self.view.superview but didn't help.

It gives error while calling function for this object as

[UIVIew unrecognized selector...... 
like image 628
Naveed Rafi Avatar asked Jan 27 '11 05:01

Naveed Rafi


1 Answers

If you're calling this directly from a UIView (and not a UIViewController), it should be self.superview instead of self.view.superview.

like image 189
omz Avatar answered Sep 20 '22 02:09

omz