2011-09-10 10 views
18

Czy możesz mi pomóc zrozumieć i/naprawić błąd poniżej. Nie rozumiem jako CustomCellView jest podklasą UItableViewCell. Kod zostanie skompilowany, ale ostrzeżenie jest nadal istnieje:Niekompatybilny typ wskaźnika inicjującego "CustomCellView *" z wyrażeniem typu UItableViewCell

Incompatible pointer type initializing 'CustomCellView *' with an expression of type `UItableViewCell` 

mam 2 linia poniżej hightlighted:

static NSString *CellIdentifier = @"CustomCell"; 
CustomCellView *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 

Odpowiedz

40
static NSString *CellIdentifier = @"CustomCell"; 
CustomCellView *cell =(CustomCellView*) [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 

musisz wpisać oddanych do celi

-1

Dla niestandardowej komórki poniżej kodu działa również dobrze z daną ramką.

CustomCell *cell= [[[CustomCell alloc] initWithFrame:CGRectZero reuseIdentifier:nil] autorelease]; 
0
static NSString *CellIdentifier = @"CustomCell"; 
CustomCellView *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; 
+0

Ta odpowiedź pojawiła się w kolejce do przeglądu niskiej jakości, prawdopodobnie dlatego, że nie podano żadnego wyjaśnienia kodu. Jeśli ten kod odpowiada na pytanie, rozważ dodanie dodania tekstu wyjaśniającego kod w odpowiedzi. W ten sposób znacznie bardziej prawdopodobne jest, że uzyskasz więcej upvotes - i pomożesz osobie pytającej nauczyć się czegoś nowego. – brandonscript

Powiązane problemy