저는 IOS 개발을 처음 접했기 때문에 무식한 질문 일 경우 사과드립니다.ARC를 켠 후 UITableViewCell.contentView 오류가 발생했습니다.
'
UILabel *label = (UILabel *)[cell.contentView viewWithTag:labelTag];
콘솔 출력은 다음과 같습니다
ARC를 사용하려면 코드를 리팩토링 후, 나는 다음과 같은 라인이 실행될 때 발생하는 SIGABRT 오류를 받기 시작했습니다 NSInvalidArgumentException '이유'- [__ NSArrayM가있는 contentView] : 미정 선택기 인스턴스 0x1acba0 '
해당 광고의 컨텍스트로 전송된다 :
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
const NSInteger labelTag = 1;
const NSInteger textFieldTag = 2;
UITableViewCell *cell = nil;
if([indexPath section] == 0) {
if([indexPath row] == 0) {
//this is the username row. Set the label accordingly.
cell = [[TextFieldCellController alloc] init];
UILabel *label = (UILabel *)[cell.contentView viewWithTag:labelTag];
label.text = @"Username";
}
else if([indexPath row] == 1) {
//this is the row that contains the password input. Set the label and
//change the textfield to use a password input style.
cell = [[TextFieldCellController alloc] init];
UILabel *label = (UILabel *)[cell.contentView viewWithTag:labelTag];
label.text = @"Password";
UITextField *text = (UITextField *)[cell.contentView viewWithTag:textFieldTag];
text.secureTextEntry = YES;
}
}
return cell;
}
콘솔 창에서 놀고 있었는데 그 줄에 중단 점을 넣은 후 "print cell.contentView"를 입력하면 "contentView라는 구성원이 없습니다."라는 메시지가 나타납니다. 그게 도움이 될지 모르겠습니다.
미리 도움을 청하십시오.
편집 :
죄송합니다, TextFieldCellController 레이블과 텍스트 필드를 포함하는 펜촉을로드있는 UITableViewCell의 하위 클래스입니다.
@implementation TextFieldCellController
@synthesize label;
@synthesize textField;
- (id)init {
self = (TextFieldCellController *)[[NSBundle mainBundle] loadNibNamed:@"TextFieldCell" owner:self options:nil];
return self;
}
메시지는'cell'이'NSArray' 인터페이스의 private 구현 인'__NSArrayM' 클래스의 객체를 가리키고 있음을 알려줍니다. 그래서 우리에게'- [TextFieldCellController init]'메소드를 보여 주라. –
TextFieldCellController 이것은 무엇입니까?, 그리고 당신은 제대로 세포를 생성하지 않습니다.이 링크를 참조하십시오 http://stackoverflow.com/questions/9494281/how-is-the-code-for-uploading-the-parsed-data- to-the-tableview/9494402 # 9494402. – Kamarshad
서브 클래스를 설명하기 위해 초기 질문을 업데이트했습니다. – Leedrick