Jak mogę udostępnić jeden xib
wśród wielu podklas UITableViewCell
?Wiele podklas UITableViewCell przy użyciu tego samego xib?
Wszystkie mają ten sam interfejs widoku, więc nie chcę powtarzać tego samego numeru xib
tylko po to, aby zmienić klasę komórki.
- (void)viewDidLoad
{
[super viewDidLoad];
[self.tableView registerNib:[UINib nibWithNibName:@"BaseCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"BaseCell"];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
BaseCell *baseCell = [tableView dequeueReusableCellWithIdentifier:@"BaseCell" forIndexPath:indexPath];
...
Co muszę tutaj zamiast jest instancją mój ChildCell
- który jest podklasą BaseCell
. Jakieś pomysły?
Zmiana struktury klasy może być lepszym podejściem. Dodawanie stanów dla komórki i reagowanie zgodnie z bieżącym stanem komórki to inna opcja. – meth