Ok, there is quite a bit of confusion in the answers already given here...
First, you're correct to not call [super loadView];
, see - (void)loadView
:
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.
If you really mean to use loadView
(i.e. creating your view programmatically, and not from a NIB), then in your implementation you must assign the view
property of your controller.
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).
Based on these considerations, your method would look like this:
-(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];
}
Of course, if you use a NIB to define your root view, you need to override -viewDidLoad:
for additional configuration.
Hope this helps.