Questions tagged [superview]
137 questions
51
votes
3 answers
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…

Naveed Rafi
- 2,503
- 5
- 32
- 40
37
votes
3 answers
iOS: Detect when my UIView is add in other view
CustomView *customView = [...];
[self.view addSubview:customView];
I need to detect in my CustomView class when it is added in other views or when my superview changes.

Jeremy Grenier
- 674
- 1
- 6
- 8
19
votes
4 answers
UIView. How Do I Find the Root SuperView Fast?
I have a random child view in a view hierarchy. What is the best/fastest/cleverest way to get to the root superview?
Cheers,
Doug

dugla
- 12,774
- 26
- 88
- 136
14
votes
3 answers
Swift find superview of given class with generics
I guess I'm struggling with generics. I want to create simple UIView extension to find recursively a superview of class passed in the function param. I want the function to return optional containing obviously either nil, or object visible as…

Chris Rutkowski
- 1,774
- 1
- 26
- 36
11
votes
5 answers
iPhone: calling a parent/super method from a subview
hope someone can help me on this as been stuck for hours.
I am trying to make a kind of picture book.
I have a view which is my container and I add subviews to that by using addsubview.
On the subview, I have swipe gestures etc that I want to…

Burf2000
- 5,001
- 14
- 58
- 117
10
votes
2 answers
create a view programmatically with frame set to superview's frame?
I have a navigation based application where I place my custom views in the navigation view.
First, I wanna know how to get the "navigation view"'s frame so that I can place my custom view on it properly.
Also, I sometimes hide navigation bar and…

eugene
- 39,839
- 68
- 255
- 489
9
votes
2 answers
How to make a subview fill its superview
I can't find the answer here anyway, nor do I see a duplicate question.
My code is simple. Given 3 UIView, parent, from and to, remove from from parent and add subview. + add animation but that's just doodads.
Now, the problem is when I do that, the…

user4951
- 32,206
- 53
- 172
- 282
9
votes
5 answers
Getting UITableViewCell with superview in iOS 7
I'm getting the UITableViewCell a UIButton belongs to like this:
-(void)buttonHandler:(UIButton *)button {
OrderCell *cell = [[button superview] superview];
NSLog(@"cell.item = %@", cell.item.text);
And it works fine in anything before iOS…

thehindutimes
- 321
- 1
- 6
- 19
9
votes
6 answers
black screen - superview is nil in viewWillAppear
I have an application created from the tabbed application template. (ARC, iOS 4)
There are several tabs and there is a button on the 2. tabs viewcontroller.view(ViewCont2).
This button loads another viewcontroller's(ModalViewCont) view by…

lockedscope
- 965
- 17
- 45
6
votes
1 answer
Superview ignores UserInteractionEnabled = NO?
I have a subview thats goes onto the screen animated, and when it is on the screen, I want the superview (in my case, the view in the background), to ignore touch events.
I tried everything but it does not work.
Is there any way to 'force' the…

SimplyKiwi
- 12,376
- 22
- 105
- 191
6
votes
6 answers
UITableViewCell indexPath crash in iOS7
I've a UITableViewCell in a UITableViewController.
In my cell there is a button that when you click takes you to another view with a prepareforsegue.
In prepareForSegue I do this:
if ([[segue identifier] isEqualToString:@"MySegue"])
{
…

Pinturikkio
- 1,490
- 1
- 14
- 28
5
votes
5 answers
removeFromSuperview causes my app to crash
I'm sure this is some stupid mistake, but i'm trying for the past hour to remove a subview from my superview without any success.
On my first view i'm having
UIViewController *helpView = [[[UIViewController alloc] initWithNibName:@"HelpView"…

Shai Mishali
- 9,224
- 4
- 56
- 83
5
votes
1 answer
How to get outermost parent UIView container?
How can I get grand gran parent view of my current self UIView, currently I'm using self.superview?.superview?.superview?.superview?.superview?.superview?
It looks kind of weird, instead of using above syntax is their any other way to get main…
user4911813
5
votes
2 answers
superview and parentviewcontroller nil after adding a subview
I think I'm missing something fundamental and so I want to ask the community for some help. I'm building an app based around a basic iPhone Utility Application. My MainView and FlipsideView share some elements so I have created separate…

deadroxy
- 1,699
- 2
- 17
- 22
4
votes
2 answers
(iphone) set subview's frame outside of superview's bound?
I noticed that I can place subview outside of superview's bound (either partly or fully).
I wonder if that's acceptable, since it seems to be abnormal in usual iphone view programming.
Thank you.

eugene
- 39,839
- 68
- 255
- 489