여기 새내기, 그냥 배우기!맞춤 셀 및 UITableViewCell 문제
사용자 정의 셀이 3 개인 표보기 앱을 만들려고합니다. 각 셀에는 왼쪽에 a 레이블과 이미지가 있어야합니다 (지금까지는 레이블 부분에만 신경을 썼습니다). 지금까지 this guide
은 매우 유용합니다. 세 항목을 가진 배열을 만들었고 제대로로드 할 수있었습니다. 그러나 사용자 정의 셀을 구현하려고 시도했을 때 모든 것이 손상되었습니다. 코드의이 부분의 경우 :
(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"CustomCell";
CustomCell *cell = (CustomCell *)
[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil){
NSArray *topLevelObjects = [[NSBundle mainBundle]
loadNibNamed:@"CustomCell"
owner:nil options:nil];
for(id currentObject in topLevelObjects)
{
if ([currentObject isKindOfClass:[UITableViewCell class]])
{
cell = (CustomCell *) currentObject;
break;
}
}
}
cell.issue.text = array objectAtIndex:[indexPath.row];
return cell;
}
나는 오류 Unused variable CellIdentifier
, CustomCell undeclared
, Expected expression before) token
및 Control reaches end of non-void function
를 얻을.
나는 무엇이 이들을 일으키는 지 알지 못한다. 나는 무엇을 찾아야할지에 대한 나의 지식만큼 막 다른 골목에 서있다. 내 초능력에 대해 유감스럽게 생각하고 올바른 방향으로 향하는 것은 인정 될 것입니다.
편집 : Heyooo! 고맙습니다. CustomCell을 가져 오면 많은 문제가 해결되었습니다! [배열 계산] 이제 프로그램을 실행하기 전에 눈에 보이는 오류는 없다,하지만 난 시도하고 그것을 실행할 때, 난 그냥 돌아 빨간색 가리키는 화살표와 함께
// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [array count];
로 전송받을;
내가 가진 현재의 배열 코드는 다음과 같습니다
- (void)viewDidLoad {
[super viewDidLoad];
array = [[NSMutableArray alloc] init];
[array addObject:@"Eleven"];
[array addObject:@"Ten"];
[array addObject:@"Nine"];
와우, 어떤 도움과 반응 커뮤니티입니다. 너에게 충분히 감사 할 수 없다.
빨간색 화살표를 클릭하면 문제와 관련된 메시지가 표시됩니까? Xcode4에서 Cmd-4를 사용하여 빌드 오류를 볼 수 있습니다. – dredful