Questions tagged [subview]

subview is an abstract representation of a nested hierarchy of views in a MVC framework

A subview can be defined either explicitly as a separate class, or implicitly via object composition, depending on the framework.

References

1264 questions
7
votes
2 answers

Load a UINavigationController as a subview from UIViewController

I am a newbi in iPhone development.I want to build an app which will have a UIViewController first , which will have a button.Now on clicking the button, it shud load a UINavigation controller. Here is how i m approaching : i created a…
XcoderMi2
  • 225
  • 2
  • 3
  • 13
7
votes
3 answers

UISlider won't work when it becomes a subview of a UIView other self.view

When I add my slider as subview of any view besides self.view it does not work (doesn't slide) but it works fine when it is a subview of self.view. You can see it on the other views besides self.view but it doesn't work. Here is my code: alphaSlider…
Aspyn
  • 647
  • 1
  • 10
  • 25
7
votes
4 answers

When to subclass UIViewController for custom subview?

I've seen custom subviews implemented as an UIViewController subclass, but that maybe could have been implemented as an UIView subclass. When should I subclass UIViewController instead of UIView for a subview? Are there any drawbacks to subclassing…
hpique
  • 119,096
  • 131
  • 338
  • 476
7
votes
3 answers

Warning from iOS "Do not add subviews directly to the visual effect view itself"

I have a function below and when I link with the iOS 11 SDK, I get an error: Do not add subviews directly to the visual effect view itself, instead add them to the -contentView. The problem can be solved by changing let effectView =…
user1453063
  • 71
  • 1
  • 3
7
votes
1 answer

Get the frame of a UIStackView subViews

I have created a UIStackView in IB which has the distribution set to Fill Equally. I am looking to get the frame for each subView but the following code always returns (0, 0, 0, 0). class ViewController: UIViewController { @IBOutlet weak var…
Wozzer
  • 73
  • 1
  • 1
  • 5
7
votes
3 answers

speed of UIView add/remove subview versus hiding/showing

Let's say I have a full-screen UIView that overlays the main screen when a button is touched, and then goes away when this overlayed view is touched. This UIView could either be added and removed from the current view using addSubview: and…
Hari Ganesan
  • 532
  • 4
  • 18
7
votes
2 answers

iPhone position of a subview?

I add a view dynamically, but when it appears on the form, it's in the upper left hand corner. Where do I set the X and Y of the new subview?
Ian Vink
  • 66,960
  • 104
  • 341
  • 555
7
votes
1 answer

How to add a subview to an ImageView in Android

I come from an iOS background. For some reason, I cannot figure out how to add a view to another view. I have two ImageViews that I am creating programatically as follows: ImageView imageView; ImageView imageHolder; Now, I want to do something like…
wiseindy
  • 19,434
  • 5
  • 27
  • 38
7
votes
3 answers

Objective-c adding Subviews to the bottom of view

Is there any way to add subview in the "bottom" of its view,like z=0 when you use layers? I need this because when I spawn objects they need to be under another pictures,not above.
Mathemage
  • 315
  • 4
  • 13
7
votes
2 answers

setNeedsDisplay does not trigger drawRect in subviews as expected

I'm struggling with setNeedsDisplay. I thought it was supposed to trigger calls of drawRect: for the view for which it is called and the hierarchy below that if it's within the view's bounds, but I'm not finding that to be the case. Here is my…
Victor Engel
  • 2,037
  • 2
  • 25
  • 46
6
votes
3 answers

Window subview not rotating after orientation of the device changes

I'm creating an UIView with a label inside AppDelegate and displaying it like this: [window addSubview:self.roundedCornerView]; Problem is when I rotate the device the view with label don't rotate at all. The text in the label is in wrong…
Ertai
  • 1,735
  • 2
  • 23
  • 29
6
votes
1 answer

android get all subviews of a view

I want to get all children of a RelativeLayout. I get this using the code: aditionView.getAllChildren(). But now the subviews are coming in the order in which it is added into that view. But i want them in the increasing order of position in which…
Priyanka V
  • 834
  • 2
  • 12
  • 34
6
votes
1 answer

How to handle relative positioning in iOS automatically?

I want to position a sub UIView (sub_UIView) as a subview of parent UIView (parent_UIView). When the parent_UIView resizing/moving, the sub_UIView would stay the relative position of the parent_UIView. For example, the sub_UIView is at the bottom…
androidkc
  • 689
  • 2
  • 7
  • 16
6
votes
2 answers

how to keep a uiview above other views

I have two views (UIView) set-up: parent and child view. The child view is displayed on top of the parent view, as desired. However I need to add subviews now that I would like to be displayed below the child view, but above the parent view. What…
andrewz
  • 4,729
  • 5
  • 49
  • 67
6
votes
2 answers

How to place a subview in the center of parent view using .center?

I have two subviews: the purple one belongs to a main view and it works wonderful with the syntax: sSubview.center = view.center The orange one belongs to the purple view and the same syntax doesn't place it correctly in the center. Could you see…
Roman
  • 759
  • 2
  • 9
  • 23