특정 뷰 컨트롤러 만 사용할 코드가 적습니다. 뷰 컨트롤러는 다른 컨트롤러와 클래스를 공유합니다.
push segue 식별자를 기반으로 if 문을 대상으로 할 수 있습니까?
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UIAlertView *messageAlert = [[UIAlertView alloc]
initWithTitle:@"Row Selected" message:@"Added to Routine!" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
내 prepareForSegue:
방법에 IF 문이 있지만 내 방법에 IF 문 이 있고 싶습니다.didSelectRowAtIndexPath:
if ([segue.identifier isEqualToString:@"ShowSightingDetails"])
나는 주위를 둘러 보았지만 이것과 직접적으로 관련된 것을 볼 수 없다.
이것은 제가 생각하기에 상당히 간단한 것이어야합니다.
스토리 보드의 셀에 대해 다른 셀 식별자를 지정했다고 가정합니다. 당신의 세포를 얻을 수 tableView:didSelectRowAtIndexPath:
과를 확인 reuseIdentifier
. 코드는 다음과 같을 수 있습니다.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath
{
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
if ([cell.reuseIdentifier isEqualToString:@"Identifier1"]) {
// Do something
} else if ([cell.reuseIdentifier isEqualToString:@"Identifier2"]) {
// Do something different
}
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다