여기에서 모든 예제를 읽은 후 UITableViewCell에 단추를 추가하기 위해 다음 코드를 작성했지만 셀에 표시 할 수 없습니다. 내가 도대체 뭘 잘못하고있는 겁니까?UITableViewCell에 UIButton이 표시되지 않습니다.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease];
}
UIButton *cellButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[cellButton setFrame:CGRectMake(0.0f, 5.0f, tableView.frame.size.width-2, 44.0f)];
[cellButton setTitle:[aList objectAtIndex:indexPath.row] forState:UIControlStateNormal];
[cell.contentView addSubview:cellButton];
[cellButton release];
return cell;
}
감사합니다, 존
당신이buttonWithType
을 통해 생성 한 버튼을
release
를 호출 할 필요가 없습니다
그건 ... 너보다! – user278859