Note that there are some explanatory texts on larger screens.

plurals
  1. POIn Interface Builder, how can I add UIViews to a subview that is a part of a custom view I've created?
    primarykey
    data
    text
    <p>I am working to create a custom view for an iPhone app I'm creating. This custom view is a Popover dialog which is made up of a UIView which contains two images, a button to close the dialog, a label, and a UIScrollView. This view is named MDPopoverCard. I have these files as a part of my view:</p> <pre><code>MDPopoverCard.xib - The view as drawn up in Interface Builder. MDPopoverCard.h - Defines a few IBActions and some other properties MDPopoverCard.m - Implements some functions defined in the header </code></pre> <p>This is what it looks like in Interface Builder: <a href="http://cl.ly/2B0f2x3s1w1i0K2G0Q1r" rel="nofollow">http://cl.ly/2B0f2x3s1w1i0K2G0Q1r</a> (sorry, I can't post an image yet as I'm new to stackoverflow)</p> <p>There are a few properties defined in my .m and .h files that control whether the green button is displayed and what the text of the title label is.</p> <p>I need to display a number of these dialogs in my app and I'd like to reuse this interface I've designed. I want to be able to add buttons and other form elements into the UIScrollView via Interface Builder. However, I have a problem:</p> <p>Imagine that I have another view I'm drawing up in Interface Builder. I add a UIView to it and set its class to MDPopoverCard. I then drag a couple UIButton objects into my MDPopoverCard view. Here's an example of what it looks like in Interface Builder:</p> <p><a href="http://cl.ly/1X090h1t1q3f0i3E0917" rel="nofollow">http://cl.ly/1X090h1t1q3f0i3E0917</a></p> <p>This screenshot shows another view (the root view) that I've added my MDPopoverCard to. I've then added two buttons as subviews of MDPopoverCard.</p> <p>These buttons do get properly nested in Interface Builder. However, when I run my app these buttons are added <em>before</em> any of the items that make up my MDPopoverCard view in the xib file. This means that the buttons are being added <em>behind</em> my popover dialog. That's the first problem.</p> <p>The second problem is that I want these buttons and form elements to actually be added into the UIScrollView that's contained within the MDPopoverCard view, and not just right into the UIView's subviews array. Is there a way to specify this in Interface Builder? I'd really much rather draw buttons into my UIView and connect them to IBActions via Interface Builder than hand write every instance of these dialogs that I may need to display (several).</p> <p>Any advice? Is there anything I can do to clarify the question?</p> <p>Thanks for your help!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload