我已经初始化了一个 QLabelElement,然后想更新它的值。但是,在 QLabelElement 实例上显式设置 .value 属性不会更新其值。这是我正在尝试做的一个片段。 onSelected 委托(delegate)在按下 sayHello 按钮时执行,但标签元素没有更新:
@implementation 我的 Controller
{
QLabelElement *_theLabel;
}
- (id)初始化
{
self = [ super 初始化];
QRootElement *root = [[QRootElement alloc] init];
QSection *section = [[QSection alloc] init];
_theLabel = [[QLabelElement alloc] initWithTitle:@"标签"值:@""];
QSection *sectionButton = [[QSection alloc] init];
QButtonElement *sayHello = [[QButtonElement alloc] initWithTitle:@"Say Hello"];
[添加到根目录的部分和控件等]
sayHello.onSelected = ^{
_theLabel.value = @"你好已经说过";//<-- 这不起作用
};
//设置 _theLabel.value = @"Hello has been said"在这里有效,但在委托(delegate)中无效
self.root = 根;
回归自我;
}
最佳答案
您需要在加载后重新加载该元素的单元格。另外,要小心保留循环,使用弱变量:
__weak QLabelElement *weakLabel = _theLabel;
sayHello.onSelected = ^{
weakLabel.value = @"Hello has been said"; //<-- this isn't working
[self.quickDialogTableView reloadCellForElements:weakLabel, nil];
};
QD 有一个分支可以自动解决这个问题,但它肯定还没有准备好使用。
关于ios - 如何更新 QLabelElement 的值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15819102/