티스토리 뷰


didSelectRowAtIndexPath는 TableView를 사용할 경우 지정된 행이 선택되었는지 알려줍니다.


tableView:didSelectRowAtIndexPath:

Tells the delegate that the specified row is now selected.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

Parameters

tableView

A table-view object informing the delegate about the new row selection.

indexPath

An index path locating the new selected row in tableView.

Discussion

The delegate handles selections in this method. One of the things it can do is exclusively assign the check-mark image (UITableViewCellAccessoryCheckmark) to one row in a section (radio-list style). This method isn’t called when the editing property of the table is set to YES (that is, the table view is in editing mode). See "€œManaging Selections" in Table View Programming Guide for iOS for further information (and code examples) related to this method.

Availability

  • Available in iOS 2.0 and later.

See Also

  • – tableView:willSelectRowAtIndexPath:
  • – tableView:didDeselectRowAtIndexPath:

Declared In

UITableView.h



[사용 예]

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

{

UINavigationController *mainNavCon = self.navigationController;

if(indexPath.row == 0) //indexPath0 일때 = 첫번째 행이 선택되었을때

{

FirstXib *firstView = [[FirstXib alloc]initWithNibName:@"FirstXib" bundle:nil];

[mainNavCon pushViewController:firstView animated:YES];

}

else {

SecondXib *secondView = [[SecondXib alloc]initWithNibName:@"SecondXib" bundle:nil];

[mainNavCon pushViewController:secondView animated:YES];

}


}