Вопрос

I have a view controller with several tables. I want one table to have larger cells than the others. Right now, I have:

- (CGFloat *)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (tableView != myBigTable)
    {
        return 44;
    }
    else
    {
        return 88;
    }
}

I get a warning saying

Incompatible integer to pointer conversion returning 'int' from a function with result type 'CGFloat *' (aka 'float *')

and when I run it, it crashes.

I've also tried:

  • return 44.0 - error for double to float* conversion
  • return 44.0f - error for float to float* conversion
  • CGFloat *height; height = 44; return height; - same errors as just returning the value I want directly

I've looked for something like [CGFloat floatWithDouble:44.0]; as is done with an NSNumber, but I haven't found anything. What am I supposed to be using?

Это было полезно?

Решение

Your function declaration is wrong. It must be

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

The return type is CGFloat and not CGFloat *.

Другие советы

You should use

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;

and remove the * after your return type.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top