iPadのSplitView Appを作成しています。ここでは、左に(横向き)、DetailViewを右に(何も新しいものはありません。表のセルをクリックすると、detailViewにセルの詳細が表示されます。 私はdetialView上のボタンを次のセルに移動し、ボタンを押して前のセルに移動します。iPadでDetailViewからボタンをクリックするとdidSelectRowAtIndexPathが呼び出されます
私の問題は、ボタンをクリックするたびに左側のテーブルビューでセルの選択を変更して、ユーザーが現在セルを知っていることです。
tableView:didSelectRowAtIndexPath:メソッドを呼び出してみましたが、NSIndexPath権限を設定できないようです(次のセルの番号を示す整数を送信したい)。ここで
はselectRowAtIndexPathを呼び出すためにtrzingのコードです:メソッド:
iPadHelloWorldAppDelegateはAppDelegateです。 masterViewControllerは、その上にテーブルがあるマスタコントローラです。
// method to set the image for the previous letter
-(IBAction)previousLetter{
iPadHelloWorldAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
NSLog(@"IndexOfImage equals: %@", appDelegate.indexOfImage);
int number = [[appDelegate.indexOfImage substringFromIndex:5] intValue];
NSString *imageName = [NSString stringWithFormat:@"image%@.png",[NSString stringWithFormat:@"%d", number-1]];
[self.letterImageView setImage:[UIImage imageNamed:imageName]];
NSLog(@"Image name: %@", imageName);
appDelegate.indexOfImage = [imageName substringToIndex:6];
NSIndexPath *currentPath = appDelegate.currentPath;
NSIndexPath *nextPath = [NSIndexPath indexPathForRow:currentPath.row-1 inSection:currentPath.section];
[masterViewController.tableView selectRowAtIndexPath:nextPath animated:YES scrollPosition:UITableViewScrollPositionNone];
NSLog(@"currentPath: %@", currentPath);
appDelegate.currentPath = nextPath;
NSLog(@"nextPath: %@", nextPath);
助けてください...
[ここ](http://stackoverflow.com/questions/2035061/select-tableview-row-programmatically)があなたの問題に対処しています。あなたが探しているものと正確に一致するはずです。 – UPT
こんにちは、答えをありがとうが、私はすでにそれを試して、selectRowAtIndexPathは、他の男のためにしたように行を強調表示されません。どちらの答えを意味しますか?最初の 'doSomeThing'メソッド? didSelectRowAtIndexは私のために働いていません... – iPhoneNoob