Search code examples
uiviewxamarinxamarin.iosxamarin-studio

Child UIView Width


I've been developing apps in Xamarin Studio for ios devices (iPad, iPhone, iPod) and I have a problem regarding child UIViews width. I want a child UIView to have the same width as its parent, but I am unable to figure out how to do it. I am using Auto Layout on my screens setting the necessary constraints, but this only keeps my widgets on screen organized (it doesn't auto resize anything for different screen sizes on iPhone). Can someone help me achieve this? I need UIView same width as its parent.

This is how the screen looks on iPhone 6 plus

This is how the screen looks on iPhone 6


Solution

  • To be Honest, I normally do constraints in Xcode as it is easier. Right click on your nib and select Open With > Xcode Interface Builder

    Then once your nib is open ctrl click and drag from your top container view to the superview and select Equal Widths then do the same for Leading space to container, Top space to container, for height ctrl click drag on to itself(top container view) and set the height.

    image1

    image2

    image3

    If you're having difficulties it might be best to upload the nib to github so I can have a look.