Can't get view to load after following iPhone SDK Final tutorial
Hi,
I recently watched the Hello World Final SDK tutorial and I've been using that and the HelloWorld app from Apple as examples. I have the basic window-based app set up and it initializes, but I don't think the view loads. I imagine this is something really stupid that I just need to learn and if someone could help me get over this initial hump, I'd greatly appreciate it. Right now, I just want an app where I type something in the search bar and it appears in the text view below which I'll use as a foundation to make something really cool.
#import "MainView.h"
@implementation MainView
@synthesize mainText;
@synthesize searchBar;
- (void)viewDidLoad {
NSLog( @"At least the delegate loads." );
searchBar.delegate = self;
}
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText {
// When the user presses return, take focus away from the text field so that the keyboard is dismissed.
[self resignFirstResponder];
// Invoke the method that changes the greeting.
mainText.text = searchText;
NSLog( @"This should have been set.");
}
- (void)dealloc {
[string release];
[mainText release];
[searchBar release];
[super dealloc];
}
@end
In the console I only see the following message:
[Session started at 2008-08-06 22:29:43 +0200.]
2008-08-06 22:29:45.465 My[879:20b] Initialized.
I get no errors. I know it's initializing, but it's not running ViewDidLoad. Perhaps I have to specifically call the view to load? Anyway, as I said, if anyone could help, I'd greatly appreciate it. I'm using iPhone SDK Final. Thanks in advance!
The thing I can't figure out is that I can indeed see the view fields in the iPhone Simulator, it's just the search field doesn't do anything nor does viewDidLoad even run. I'm guessing the Interface Builder already set up some kind of relationship from the window to the MainView, but I don't know how you would access it. Any ideas?
Final Update for Today: I believe I need to set up the project anew for a View-based application instead of a Window-based application, so I can get a View Controller. I'm pretty sure how to do it now, but I'm quite too tired tonight to keep on. I'll update again tomorrow with my progress.
I'm not sure if you figured this out or not (2 months later) but, I found this thread searching for the same error message. Turns out it's just a typo, it should be addSubview (with a lowercase v) instead of addSubView. I guess subview is one word, not two...
I thought it might be helpful to have this up here in case anyone else stumbles across this with google...
I'm not sure if you figured this out or not (2 months later) but, I found this thread searching for the same error message. Turns out it's just a typo, it should be addSubview (with a lowercase v) instead of addSubView. I guess subview is one word, not two...
I thought it might be helpful to have this up here in case anyone else stumbles across this with google...
-Jeremy
Thank you for posting this. I wasted about an hour trying to figure this out before I searched this forum.