添加一个 uilabel 没有改变的 uiviewcontroller
我正在添加一个 UIViewController,它只有一个 UILabel 到主 UIView 中。我这样创建它:(
WEPopoverLabel *contentViewController = [[WEPopoverLabel alloc] init];
[contentViewController setContents:@"aaa"];
漏洞代码.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];
}
嗯,正在创建 WEPopoverLabel,因为它显示在我的窗口中,并且还执行 setContents,因为我有一个 NSLog 在我的控制台中打印。
然而,标签并未改变。这是 WEPopoverLabel 的内容:
@interface WEPopoverLabel : UIViewController{
IBOutlet UILabel * lContent;
}
-(void)setContents:(NSString *) theContent;
和 .m
@implementation WEPopoverLabel
-(void)setContents:(NSString *) theContent{
lContent.text = theContent;
NSLog(@"texto fijado");
}
在 .xib 中,我已将 lContent 连接到文件的所有者。
为什么 UILabel 的文本没有更新?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 UIViewController 中,您是否已将 xib 中的主视图连接到文件所有者并连接标签?
另外,您是否在创建视图后将 WEPopoverLabel 添加到视图中:
[currentView addSubview:contentViewControler]
我会给标签提供背景颜色,以便您可以判断它是否确实显示。
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.
没错。检查这个:
http://forums.macrumors.com/showthread.php?t=1002736
或者
在这个方法中:
thats correct. check this:
http://forums.macrumors.com/showthread.php?t=1002736
Or
and in this method: