0
배열로 채워진 UITableView를 만들고 그린려고합니다. UIViewController를 만들고 UIViewController를 내 tableview의 대리자로 설정했습니다. 그러나, 내 cellForRowAtIndexPath 메서드는 테이블 뷰가 만들어 질 때 호출되지 않으므로 내 테이블이 채워지지 않습니다. 내가 여기서 무엇을 놓치고 있니? (모든 레이블은 그 함수에서 초기화됩니다. 테이블을 사용하여 Main Menu를 만들려고하는데 모든 항목이 고정됩니다).델리게이트 세트 후에도 iPhone 프로그래밍 cellForRowAtIndexPath가 호출되지 않습니다.
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
prefTable = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320, 480) style:UITableViewStylePlain];
[prefTable setDelegate:self];
//NSIndexSet *tmpIndRange = [[NSIndexSet alloc] initWithIndexesInRange:NSMakeRange(0,1)];
//[prefTable insertSections:tmpIndRange withRowAnimation:UITableViewRowAnimationNone];
//[tmpIndRange release];
labelArray = [[NSMutableArray alloc] initWithCapacity:10];
[labelArray addObject:NSLocalizedString(@"Account ID",@"C_ACC_ID")];
[labelArray addObject:NSLocalizedString(@"Site ID",@"Site_ID")];
[labelArray addObject:NSLocalizedString(@"Station ID",@"Station_ID")];
[labelArray addObject:NSLocalizedString(@"Encryption Key",@"ENC_KEY")];
[labelArray addObject:NSLocalizedString(@"Encryption On",@"ENC_ON")];
placeholderArray = [[NSMutableArray alloc] initWithCapacity:10];
[labelArray addObject:NSLocalizedString(@"Required",@"Required")];
[labelArray addObject:NSLocalizedString(@"Required",@"Required")];
[labelArray addObject:NSLocalizedString(@"Required",@"Required")];
[labelArray addObject:NSLocalizedString(@"Required",@"Required")];
[labelArray addObject:NSLocalizedString(@"Required",@"Required")];
self.view = prefTable;
}
-(BOOL)textFieldShouldReturn:(UITextField *)textField {
NSInteger currenttag = textField.tag;
NSLog(@"%d",textField.tag);
//accountId = textField.text;
//stationId = textField.text;
//siteId = textField.text;
[textField resignFirstResponder];
return YES;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
// Set up the cell...
[cell setAccessoryType:UITableViewCellAccessoryNone];
[cell.textLabel setText:[labelArray objectAtIndex:indexPath.row]];
//((TextInputTableCell *)cell).textField.placeholder = [placeholderArray objectAtIndex:indexPath.row];
return cell;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 4;
}
또한 데이터 소스를 사용하여 메뉴 항목을 할당하면 더 좋을까요? 섹션 헤더는 데이터 소스를 통해서만 할당 할 수 있습니다. 감사!
예 ... 나는 그게 생각 : 당신은 당신의 컨트롤러에게 jQuery과의 데이터 소스를 확인해야합니다. – futureelite7