1 つのクラスで複数の UITableView を使用していますが、デリゲートでそれらを分離することはできません。なぜこれが機能しないのですか:
- (UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
MenuHeader *header;
if (tableView == myFirstTable) {
header = [[MenuHeader alloc] initWithFrameAndTitel:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 40) :@"Text for first table"];
}
else if (tableView == mySecondTable) {
header = [[MenuHeader alloc] initWithFrameAndTitel:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 40) :@"Text for second table"];
}
return header;
}
if ステートメントにブレークポイントを設定しましたが、ヘッダーが設定されません。同じことが起こります
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {}
@implementation の下でテーブルビューを宣言しました。
UITableView *myFirstTable;
UITableView *mySecondTable;
UITableView *myThirdTable;
次に、初期化子で:
myFirstTable = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 180)];
myFirstTable.dataSource = self;
myFirstTable.delegate = self;
[self addSubview:myFirstTable];
...
編集
より多くのコード:
@implementation TableStuff
@synthesize delegate = _delegate;
UITableView *myFirstTable;
UITableView *mySecondTalbe;
UITableView *myThirdTable;
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
myFirstTable; = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 180)];;
menuTable.dataSource = self;
menuTable.delegate = self;
[self addSubview:menuTable];
mySecondTable = [[UITableView alloc] initWi....
more init...
}
return self;
}