Ios 更改自定义表格视图单元格按钮的边框

Ios 更改自定义表格视图单元格按钮的边框,ios,objective-c,uitableview,Ios,Objective C,Uitableview,在我的应用程序中,我在UITableView中显示待售商品列表。如果用户没有在项目上设置描述,我想调整单元中的一些元素的定位,以调整空白标签。 my CellForRowatineXpath中的以下代码无效 cell.productName.text = product.fields[@"title"]; cell.productPrice.text = product.fields[@"price"]; cell.productDescription.text = vehicle.fields

在我的应用程序中,我在UITableView中显示待售商品列表。如果用户没有在项目上设置描述,我想调整单元中的一些元素的定位,以调整空白标签。

my CellForRowatineXpath中的以下代码无效

cell.productName.text = product.fields[@"title"];
cell.productPrice.text = product.fields[@"price"];
cell.productDescription.text = vehicle.fields[@"salespersonComments"];

if ([cell.productDescription.text isEqualToString:@""]) {

    CGRect f = cell.favoriteButton.frame;
    f.origin.y = 10; // new y
    cell.favoriteButton.frame = f;

} else {

}

与其实际更改项目的协调/框架,不如将IBOutlets连接到相关NSLayoutConstraints

然后你可以做一些类似的事情:

if ([cell.productDescription.text isEqualToString:@""]) {
    cell.favoriteButtonWidthConstraint.constant = 0;
    cell.leadingIndentConstraint.constant = 0;

} else {

}
//You have to use the UITableView delegate methods
//Method for displaying the cell
- (UITableViewCell *)tableView:(UITableView *)tableView
             cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        static NSString *MyIdentifier = @"MyIdentifier";

        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];

        if (cell == nil)
        {
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
                                           reuseIdentifier:MyIdentifier];
        }

    }

//Method for adjusting the cell height
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{

        return 80;

}