Я много искал, но не нашел ничего полезного, связанного с несколькими настраиваемыми строками, мне нужно создать таблицу настроек для моего приложения, в которой мне нужно загрузить строки из xib-файлов, например:Несколько пользовательских строк UITableView?
СТРОКА 1 = >> XIB 1.
СТРОКА 2 = >> XIB 2.
СТРОКА 3 = >> XIB 3.
СТРОКА 4 = >> XIB 4.
Мой подарок код:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell=nil;
//We use CellType1 xib for certain rows
if(indexPath.row==0){
static NSString *CellIdentifier = @"ACell";
cell =(ACell*) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(cell==nil){
NSArray *nib= [[NSBundle mainBundle] loadNibNamed:@"ACell" owner:self options:nil];
cell = (ACell *)[nib objectAtIndex:0];
}
//Custom cell with whatever
//[cell.customLabelA setText:@"myText"]
}
//We use CellType2 xib for other rows
else{
static NSString *CellIdentifier = @"BCell";
cell =(BCell*) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(cell==nil){
NSArray *nib= [[NSBundle mainBundle] loadNibNamed:@"BCell" owner:self options:nil];
cell = (BCell *)[nib objectAtIndex:0];
}
//Custom cell with whatever
//[cell.customLabelB setText:@"myText"]
}
return cell;
}
Что вы имеете в виду «» –
Mateus
Вы говорите, что хотите использовать несколько Xib, я угадываю xib1 для строки n1, xib2 для строки n2 и т. Д. Итак, оператор if/else проверяет строку индекс и на основе того, что вы хотели бы достичь, вы выбираете правильный xib в правильном индексе строки –
Главный вид моего XIB следует изменить для UITableViewCells или просто изменить размер представления? – Mateus