I'm have a map view with a number of annotations on it... once the callout is clicked, i need to pass several parameters to the DetailViewController, so ive been trying to do this through the constructor. I've debugged a bit and discovered that the arguments are being passed properly and are being received as expected within the constructor, but for some reason whenever I try to change the values of the IBOutlets I've positioned in the nib, it never has an effect.
Here's what im passing (btw, im getting a "No initWithNibName : bundle : header' method found" warning at this line):
DetailViewController *dvc = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil header:headerText];
[self.navigationController pushViewController:dvc animated:YES];
Now heres my constructor:
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil header:(UILabel*)headerLabel {
if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
self.headerTextView = headerLabel;
NSLog(@"header:%@", headerLabel.text);
}
return self;
}
Once again, the problem is that headerLabel.text is printed properly in the console, but the line self.headerTextView = headerLabel;
doesnt seem to be doing what I want it to do.
Thanks! edit:
DetailViewController header:
#import <UIKit/UIKit.h>
#import "Truck.h"
@interface DetailViewController : UIViewController
{
IBOutlet UITextView *informationTextView;
IBOutlet UIImageView *imageView;
IBOutlet UIWebView *twitterFeedView;
IBOutlet UILabel *headerTextView;
NSString *imageURL;
}
@property (nonatomic, retain) NSString *imageURL;
@property (nonatomic, retain) UILabel *headerTextView;
@property (nonatomic, retain) UITextView *informationTextView;
@property (nonatomic, retain) UIImageView *imageView;
@property (nonatomic, retain) UIWebView *twitterFeedView;
-(DetailViewController*)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil header:(UILabel*)headerLabel;
@end
relevant DetailViewController implementation:
@synthesize imageView, informationTextView, twitterFeedView, headerTextView, imageURL;
// The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil header:(UILabel*)headerLabel {
if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
self.headerTextView = headerLabel;
NSLog(@"r%@", headerLabel.text);
}
return self;
}