변수를 뷰 컨트롤러에서 다른 컨트롤러로 전달하여 사용자가 첫 번째 테이블 뷰에서 특정 행을 선택하면 응용 프로그램이 그를 선택한 항목의 세부 정보가 표시되는 다른 뷰 컨트롤러로 이동시킵니다. . 이 내 코드입니다 :didSelectRowAtIndexPath를 사용하여 uitableview에서 두 번째 tableview로 변수를 전달하는 방법은 무엇입니까?
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *selectedAuthors = [theauthors objectAtIndex:indexPath.row];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
Details *dvController = [storyboard instantiateViewControllerWithIdentifier:@"Details"]; //Or whatever identifier you have defined in your storyboard
dvController.selectedAuthors = selectedAuthors;
UIAlertView *messageAlert = [[UIAlertView alloc]
initWithTitle:@"Row Selected" message:authorNAme delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
// Display Alert Message
authorNAme = [[NSString stringWithFormat:[theauthors objectAtIndex:indexPath.row]] intValue];
[messageAlert show];
[self.navigationController pushViewController:dvController animated:YES];
}
selectedAuthors 문자열 AUTHORNAME 내가 선택한 행의 컨텐츠를 저장하고자하는 전역 변수입니다. 도움이 될 것입니다.
에 의해 이미 "데이터"를 두 번째보기 컨트롤러에 전달하고 있습니다. details 뷰 컨트롤러에서 selectedAuthors를 기반으로 세부 정보를 표시해야합니다. – Moxy
특정 문제가 표시 될 링크를 확인하십시오. http://stackoverflow.com/questions/11897149/how-to-send-the-details-of-a-selected-cell-to-another-view-controller –