-5

テーブルビューには7行が含まれており、そのうち1行を選択してから、xibグローバルデータを含む他のファイルへの転送を制御する必要があります。

それはどのように可能ですか?

4

3 に答える 3

3
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
}
于 2013-02-23T09:43:33.403 に答える
2
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

このメソッドは、テーブルビューの行の 1 つをクリックすると呼び出されます。

編集:このメソッド内でこのようなアラートを表示できます

 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    UIAlertView *message = [[UIAlertView alloc] initWithTitle:@"Hello World!"
                                                      message:[NSString stringWithFormat:@"This is your UIAlertview message with row number %d.",indexPath.row];                                                     delegate:nil
                                            cancelButtonTitle:@"OK"
                                            otherButtonTitles:nil];
    [message show];
    [message release];
}
于 2013-02-23T09:43:24.600 に答える
1
NSMutableArray *mealArray = [[NSMutableArray alloc] init];

 - (void)viewDidLoad
 {   
      mealArray = [[NSMutableArray alloc]initWithObjects:@"Breakfast",@"Lunch",@"Dinner",@"Others", nil];
 }

 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
 {
     cell.textLabel.text = [mealArray objectAtIndex:indexPath.row];
 }

 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
 {
     newViewController *newVC = [[newViewController alloc] init];
     newVC.mealType = [mealArray objectAtIndex:indexPath.row];
     [self.navigationController pushViewController:newVC animated:YES];
 }
于 2013-02-23T10:13:09.490 に答える