하나의 응용 프로그램에서 두 인스턴스의 UITableView 있고 각 테이블을 표시해야하는 정의하는 방법을 모르는 문제입니다. 여기 코드는 다음과 같습니다두 TableView 처리하는 방법
.H :
{
NSArray *array1;
NSArray *array2;
IBOutlet UITableView *table1;
IBOutlet UITableView *table2;
}
하는 .m :
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [array1 count];
}
- (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];
}
cell.textLabel.text = [array1 objectAtIndex:indexPath.row];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
}
이 코드는 하나 개의 테이블에 대해 노력하고 있습니다. 배열 2로 다른 테이블을 설정하는 방법을 모르겠습니다. 아이디어 있니?
나열된 모든 위임 된 메소드에는 tableView 매개 변수가 있습니다. tableView가 table1인지 table2인지 비교하여 비교할 수 있습니다. – user523234