Initializing Detail View from nib with parameters passed from Root View

Posted by culov on Stack Overflow See other posts from Stack Overflow or by culov
Published on 2010-06-13T21:41:21Z Indexed on 2010/06/13 22:12 UTC
Read the original article Hit count: 229

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!

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c