I’m adding a UIViewController which has only an UILabel to the main UIView. I create it like this:
WEPopoverLabel *contentViewController = [[WEPopoverLabel alloc] init];
[contentViewController setContents:@"aaa"];
(The hole code .m):
if (!self.popoverController) {
WEPopoverLabel *contentViewController = [[WEPopoverLabel alloc] init];
[contentViewController setContents:@"aaa"];
contentViewController.lContent.text=@"aaarrr";
self.popoverController = [[[popoverClass alloc] initWithContentViewController:contentViewController] autorelease];
self.popoverController.delegate = self;
self.popoverController.popoverContentSize = CGSizeMake(50.0f, 20.0f);
self.popoverController.passthroughViews = [NSArray arrayWithObject:sender];
CGRect rectForPopover = [self.view convertRect:sender.bounds fromView:sender];
[self.popoverController presentPopoverFromRect:rectForPopover inView:self.view permittedArrowDirections:(UIPopoverArrowDirectionUp|UIPopoverArrowDirectionDown) animated:YES];
[contentViewController release];
}
Well, WEPopoverLabel is being created because it shows up in my window and also executes setContents because I’ve got a NSLog which is printing in my console.
However, the label is not being changed. This is the content of WEPopoverLabel:
@interface WEPopoverLabel : UIViewController{
IBOutlet UILabel * lContent;
}
-(void)setContents:(NSString *) theContent;
and .m
@implementation WEPopoverLabel
-(void)setContents:(NSString *) theContent{
lContent.text = theContent;
NSLog(@"texto fijado");
}
In the .xib, I’ve connected the lContent to File’s owner.
Why is not being updated the text of UILabel?
In the UIViewController, have you connected the main view in the xib to the file owner as well as connecting the label?
Also have you added WEPopoverLabel to the view after it is created:
[currentView addSubview:contentViewControler]I would give the label a background colour so you can tell if it is actually beng displayed.