Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is the correct way.</p> <pre><code>UIViewController *viewController = [[UIViewController alloc] init]; UIView *view1 = [[UIView alloc] init]; [viewController.view addSubview:view1]; [view1 release]; [viewController release]; </code></pre> <p>When you add a view as subview it'll be retained by the viewcontroller. addSubview:</p> <p>Adds a view to the end of the receiver’s list of subviews.</p> <blockquote> <p><code>- (void)addSubview:(UIView *)view</code></p> <p><strong>Parameters</strong></p> <p><strong>view</strong></p> <pre><code>The view to be added. This view is retained by the receiver. After being added, this view appears on top of any other subviews. </code></pre> <p><strong>Discussion</strong></p> <p>This method retains view and sets its next responder to the receiver, which is its new superview.</p> <p>Views can have only one superview. If view already has a superview and that view is not the receiver, this method removes the previous superview before making the receiver its new superview.</p> </blockquote> <p>Reference <a href="http://developer.apple.com/library/ios/#documentation/uikit/reference/uiview_class/uiview/uiview.html" rel="nofollow">UIView</a></p> <blockquote> <p>Important: A view controller is the sole owner of its view and any subviews it creates. It is responsible for creating those views and for relinquishing ownership of them at the appropriate times such as when the view controller itself is released</p> </blockquote> <p>Reference : <a href="http://developer.apple.com/library/ios/#documentation/uikit/reference/UIViewController_Class/Reference/Reference.html" rel="nofollow">UIViewController Class</a></p> <pre><code>UIView *view = (UIView *)[[viewController.view subviews] objectAtIndex:0]; [view release]; </code></pre> <p>It'll surely crash when you call release on viewController.</p>
    singulars
    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.
    1. VO
      singulars
      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