動的オプションを追加するために2つのテーブルビューを使用する必要があるページを作成しました。問題は、1つのテーブルだけがデータを表示し、もう1つはデータを表示しないことです。私はどこで間違っていたのですか?1つのUIviewcontrollerで2つのテーブルビューを追加する方法
私の見解のスクリーンショット。以下は
私のコード - を追加してい
@interface FlirtMatchViewController()
{
UILabel *headerTitle;
NSArray *tableData;
NSArray *arrimages;
NSArray *tableData1;
NSArray *arrimages1;
}
@end
@implementation FlirtMatchViewController
- (void)viewDidLoad {
[super viewDidLoad];
tableData = [NSArray arrayWithObjects:@"TattooSingles",@"Eyecatcher",@"Tattoo Toplist",@"Radar",@"Flirt Chat",@"Free VIP Membership",@"VIP Membership",@"Invite Friends",nil];
arrimages = [NSArray arrayWithObjects:@"[email protected]",@"eye_catcher.png",@"tatto_toplist.png",@"radar.png",@"Flirt_chat.png",@"free_vip.png",@"vip_membership_navigation.png",@"add-friend1.png", nil];
tableData1 = [NSArray arrayWithObjects:@"TattooSingles",@"Eyecatcher",@"Tattoo Toplist",@"Radar",@"Flirt Chat",@"Free VIP Membership",@"VIP Membership",@"Invite Friends",nil];
arrimages1 = [NSArray arrayWithObjects:@"[email protected]",@"eye_catcher.png",@"tatto_toplist.png",@"radar.png",@"Flirt_chat.png",@"free_vip.png",@"vip_membership_navigation.png",@"add-friend1.png", nil];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if(tableView==_leftTableView)
{
return [tableData count];
}
else {
return [tableData1 count];
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier2 = @"Cell2";
static NSString *CellIdentifier1 = @"Cell1";
if(tableView==self.leftTableView)
{
static NSString *CellIdentifier1 = @"Cell1";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier1];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier1] ;
}
cell.textLabel.text = [tableData objectAtIndex:indexPath.row];
return cell;
}
else
{
static NSString *CellIdentifier2 = @"Cell2";
UITableViewCell *cell1 = [tableView dequeueReusableCellWithIdentifier:CellIdentifier2];
if (cell1 == nil)
{
cell1= [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier2] ;
}
cell1.textLabel.text = [tableData1 objectAtIndex:indexPath.row];
return cell1;
}
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
TattooSinglesScreen *obj=[self.storyboard instantiateViewControllerWithIdentifier:@"TattooSinglesScreen"];
EyecatcherScreen *obj1=[self.storyboard instantiateViewControllerWithIdentifier:@"EyecatcherScreen"];
TattooToplist *obj2=[self.storyboard instantiateViewControllerWithIdentifier:@"TattooToplist"];
int i=indexPath.row;
if(i==0){
[self.navigationController pushViewController:obj animated:NO];
}
else if (i==1) {
[self.navigationController pushViewController:obj1 animated:NO];
}
else if (i==2) {
[self.navigationController pushViewController:obj2 animated:NO];
}
}
はまた、以下のコードを使用して、特定の画面に最初の3つのオプションをナビゲートしようとしています。しかし、コードは私のために働いていません。誰も私の疑問をクリアすることはできますか?
あなたの2番目のテーブルビュー名 –
_rightTableView –
didSelectの 'if(tableView == self.leftTableView)'も追加していませんか? – iphonic