テーブルビューには7行が含まれており、そのうち1行を選択してから、xib
グローバルデータを含む他のファイルへの転送を制御する必要があります。
それはどのように可能ですか?
テーブルビューには7行が含まれており、そのうち1行を選択してから、xib
グローバルデータを含む他のファイルへの転送を制御する必要があります。
それはどのように可能ですか?
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
}
- (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];
}
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];
}