2017-03-18 5 views
0

フレンド、テーブルビューのデータを配列と一緒に渡したいと思っています。テーブルビューのデータは配列で渡されます

最初のテーブルビューでカテゴリフードをクリックすると、2番目のテーブルのbarレストランの詳細オプションが表示されます。ユニークな行のビューでは、データを渡す方法がわかりません。必要に応じてコードを提供し、必要に応じてスクリーンショットを送信することができます。

first table view second table view

私はこのようにするビューを必要とし、できるだけ速く助けてください。

#import "categoryViewController.h" 

@interface categoryViewController()<UITableViewDelegate,UITableViewDataSource> 
{ 
NSArray *tableData,*thumbNails; 
} 
@property (weak,nonatomic) IBOutlet UITableView *categoryTable; 
@property (weak,nonatomic) NSArray *tabledata; 
@end 

@implementation categoryViewController 

- (void)viewDidLoad { 

    tableData = [[NSArray alloc]initWithObjects:@"Food and Drinks",@"Shopping",@"Housing",@"Transportation",@"Vehicle",@"Life and Entertainment",@"Communication & PC",@"Financial Expenses",@"Investment",@"Income",@"Others",nil]; 

//thumbnails=[[NSArray alloc]initWithObjects:@"Food and Drinks.png"@"Shopping.png",@"Shopping.png",@"Shopping.png",@"Shopping.png",@"Shopping.png",@"Shopping.png",@"Shopping.png",@"Shopping.png",@"Shopping.png",@"Shopping.png", nil]; 

[super viewDidLoad]; 
// Do any additional setup after loading the view, typically from a nib. 
} 

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection: (NSInteger)section 
{ 
return tableData.count; 
} 

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 

{ //Updated method to go to the next View. 
UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"Cell"]; 

    if (cell==nil) { 
     cell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"]; 
    } 
    //outdated method. 
    // UITableViewCell *cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"]; 

    cell.textLabel.text = [tableData objectAtIndex:indexPath.row]; 
    //cell.imageView.image = [UIImage imageNamed:[thumbnails objectAtIndex:indexPath.row]]; 
    // work on ittttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt. 

    return cell; 
    } 
    /* 
    -(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender 
    { 
NSIndexPath *index = [self.categoryTable indexPathForSelectedRow]; 
subcategoryViewController *scVC = [segue destinationViewController]; 
} 
*/ 
- (void)didReceiveMemoryWarning { 
    [super didReceiveMemoryWarning]; 
    // Dispose of any resources that can be recreated. 
} 

-(IBAction)backBtn:(id)sender{ 
    [self dismissViewControllerAnimated:YES completion:nil]; 
} 
/* 
#pragma mark - Navigation 

// In a storyboard-based application, you will often want to do a little preparation before navigation 
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 
    // Get the new view controller using [segue destinationViewController]. 
    // Pass the selected object to the new view controller. 
} 
*/ 

@end

+0

いくつかのコードと画像を追加してください。 – iOS

+0

イメージを追加しました。コードも送信します。 –

+0

in didselectrowatindexpathメソッド次のVC文字列変数に特定のインデックス値を格納 – iOS

答えて

0

あなたが望む方法、1のようなデータを渡すには、2つの方法があります@ジョン。変数を個別に作成してcontraollerをナビゲートし、segueメソッド2でそれらの値を指定するか、キー値 を使用してデータを渡すことができます。

関連する問題