예, 가능하지만 uiitableview를 3 개의 모든 viewcontroller에 추가해야했습니다.
여기 몇 가지 예 ..! 21
로하고있는 tableview 구현 파일이있는 tableview에 세트 태그이
@implementation LCsampleTableView
UITableView *tableView1;
- (id)initWithCoder:(NSCoder *)aDecoder {
// self = [super init];
self = [super initWithCoder:aDecoder];
if (self) {
tableView1 =(UITableView *)[self viewWithTag:21];
[tableView1 setDelegate:self];
[tableView1 setDataSource:self];
// [self myviewDidload];
}
return self;
}
#pragma mark - Table view start
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 2;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"tblCell"];
//cell = myCellDeque;
if(cell == nil){
// cell = myCellDeque;
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"tblCell"];
UILabel *lb1 = [[UILabel alloc] initWithFrame:CGRectMake(25, 6, 154, 20)];
lb1.tag = 1; // Set a constant for this
lb1.font = [UIFont systemFontOfSize:9.0];
[lb1 setTextColor:[UIColor whiteColor]];
lb1.backgroundColor = [UIColor clearColor];
cell.contentView.backgroundColor= [UIColor colorWithRed:7.0/255.0 green:91.0/255.0 blue:164.0/255.0 alpha:1] ;
[cell.contentView addSubview:lb1];
}
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
}
#pragma -mark tableDelete
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
//Return YES if you want the specified item to be editable.
return YES;
}
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
}
@end
처럼 구현은 다음 세 가지 컨트롤러에서 클래스와이있는 tableview를 추가 할 경우에 있었다 해달라고 3 개의 모든 컨트롤러에서이 tableview에 대한 코드. 그것은 당신이 데이터에 따라 서로 다른 데이터 소스를 표시하기와 같은`UITableViewController`을 사용할 수 있습니다이
같이있는 tableview에
추가 태그를 도움이되기를 바랍니다. 다른 셀을 사용하고 싶다면,'cellForRowAtIndexPath : – Akhilrajtr