У меня есть uiview внутри uitableviewcell (скажем, контейнер). Я хочу добавить еще один uiview в качестве подвеса в этот контейнер. Вот что я делаю. < /p>
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *cellIdentifier = @"Cell";
static NSString *expandedCellIdentifier = @"ExpandedCell";
if (!isExpanded) {
ListCell *cell =(ListCell*) [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell==nil) {
NSArray *nibs = [[NSBundle mainBundle]loadNibNamed:@"ListCell" owner:self options:nil];
cell = nibs[0];
}
cell.Name.text = [[bArray objectAtIndex:indexPath.row]valueForKey:@"Name"];
return cell;
}
else{
expCell =(ExpandedCell*) [tableView dequeueReusableCellWithIdentifier:expandedCellIdentifier]; //Made this global iVar to refrence it from other methods.
if (expCell==nil) {
NSArray *nibs = [[NSBundle mainBundle]loadNibNamed:@"ExpandedCell" owner:self options:nil];
expCell = nibs[0];
lDView = [[[NSBundle mainBundle]loadNibNamed:@"lDView" owner:self options:nil]firstObject]; //lDView is a UIView subclass.
[lDView setFrame:CGRectMake(0, 0, 225, 90)];
[lDView setBackgroundColor:[UIColor grayColor]];
//more code.
}
return expCell;
}
return nil;
}
< /code>
Теперь я добавляю это ' ldview < /em>' в подвод после заполнения его некоторыми кнопками, подобными этому. < /p>
-(void)addButtons{
//Add buttons here
[lDView.containerScrollView addSubview:btn];
[expandedCell.containerView addSubview:lDView]; //Doesn't add it to each and every table View cell.Its loading sometimes and sometimes doesn't show up.
Подробнее здесь: https://stackoverflow.com/questions/256 ... -correctly