Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Ok, there is quite a bit of confusion in the answers already given here...</p> <p>First, you're correct to not call <code>[super loadView];</code>, see <a href="http://developer.apple.com/library/ios/documentation/UIKit/Reference/UIViewController_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40006926-CH3-SW1" rel="nofollow"><code>- (void)loadView</code></a>:</p> <blockquote> <p>If you override this method in order to create your views manually, you should do so and assign the root view of your hierarchy to the view property. (The views you create should be unique instances and should not be shared with any other view controller object.) Your custom implementation of this method should not call super.</p> </blockquote> <p>If you really mean to use <code>loadView</code> (i.e. creating your view programmatically, and not from a NIB), then in your implementation you <em>must</em> assign the <code>view</code> property of your controller.</p> <p>Also, you do not need to retain your button the way you're using it, because you're adding it as a subview of your main view (your main view will own it after that).</p> <p>Based on these considerations, your method would look like this:</p> <pre><code> -(void)loadView { CGRect frame = [[UIScreen mainScreen] applicationFrame]; // adjust to your needs UIView *rootView = [[UIView alloc] initWithFrame:frame]; UIButton *chooseSubjectButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; chooseSubjectButton.frame = CGRectMake(15.0f, 205.0f, 296.0f, 51.0f); [chooseSubjectButton addTarget:self action:@selector(chooseSubject) forControlEvents:UIControlEventTouchUpInside]; [rootView addSubview:chooseSubjectButton]; self.view = rootView; [rootView release]; } </code></pre> <p>Of course, if you use a NIB to define your root view, you need to override <code>-viewDidLoad:</code> for additional configuration.</p> <p>Hope this helps.</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.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. 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