2

我正在尝试访问 QuickDialog 表单的 UITableViewCell 的属性。

更具体地说,我正在尝试访问 QEntryElement (QDateTimeInlineElement) 的附件视图属性,该属性“隐藏”在我创建的对象的属性列表中。

我正在尝试使用

    UITableViewCell *thisCell = [dateelement getCellForTableView:self.quickDialogTableView controller:self];

但由于某些原因,没有显示任何内容。我正在尝试在其中插入一个 UIButton,如下所示:

UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setTitle:@"=" forState:UIControlStateNormal];
button.frame = CGRectMake(0, 0, 24, 24);

然后 thisCell.accessoryView = button;

我是否以错误的方式访问该属性,或者根本没有创建按钮?没有显示错误,但附件视图为空。

先感谢您

4

1 回答 1

2

这个问题看起来非常接近你的要求。基本上,您首先必须提供您自己的QuickDialogStyleProvider,按照 escoz 建议的方式实施该cell:willAppearForElement:atIndexPath:方法:

一旦你在提供者方法中得到调用,你就可以完全控制单元格。您可以检查单元格是否为 type QEntryTableViewCell,如果是,则转换为该类型并更改textField属性的颜色/字体。一个很好的副作用是这也会改变所有子类的颜色,比如单选按钮、日期/时间字段等。

所以,在你的情况下,你会做类似的事情

- (void)viewDidLoad
{
    self.quickDialogTableView.styleProvider = self;
}

- (void)cell:(UITableViewCell *)cell willAppearForElement:(QElement *)element atIndexPath:(NSIndexPath *)indexPath
{
    if([cell isKindOfClass:[QDateTimeInlineElement class]])
    {
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        [button setTitle:@"=" forState:UIControlStateNormal];
        button.frame = CGRectMake(0, 0, 24, 24);

        cell.accessoryView = button;
    }
}

抱歉,如果它不完全正确,我现在远离 Xcode。

于 2012-07-26T17:55:31.967 回答