상세 컨텐츠

본문 제목

[iOS 개발] TableView를 사용할 경우 행이 선택되었는지 확인해주는 메소드

헉!!/iOS

by 권태성 2011. 8. 4. 22:51

본문


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];

}


}

 

관련글 더보기

댓글 영역