2012-03-25 4 views
0

나는 별개의 클래스에서 사용자 정의 uitableviewcell을 작성하고이를 uitableview의 viewcontroller에서 사용합니다. 이제 사용자 정의 uitableviewcell에서 버튼을 클릭하면 다른 페이지로 이동하려고합니다. 누군가 나를 도울 수 있습니까?사용자 정의 uitableviewcell에서 내비게이션

-(IBAction)followUser:(id)sender { 
    NSLog(@"memberid %d",self.memberid); 
    profileViewController *profile = [[profileViewController alloc] init]; 
    [((UIViewController*) sender).navigationController pushViewController:profile animated:FALSE]; 

} 

그러나 충돌되어 다음

이있는 UITableViewCell에 버튼 클릭에 대한 조치의 내 코드입니다.

답변

0

[profileViewController alloc]이 잘못되었습니다. 인스턴스 변수가 아니라 객체의 실제 클래스가 할당되기를 원합니다.

1

작업 메서드의 보낸 사람 매개 변수 'followUser :'는 메서드를 호출 한 컨트롤을 나타냅니다. 아마도 UIButton 일 것입니다. 그리고 분명히 UIButton에는 'navigationController'속성이 없습니다. 코드가 탐색 스택에있는 UIViewController 하위 클래스 내에 있으면 해당 하위 클래스에 'navigationController'속성이 있습니다.이 속성을 통해 UINavigationController에 액세스 할 수 있습니다. 이 시도하지 : 'profileViewController의 ALLOC'문제

-(IBAction)followUser:(id)sender { 
NSLog(@"memberid %d",self.memberid); 
profileViewController *profile = [[profileViewController alloc] init]; 
[self.navigationController pushViewController:profile animated:FALSE]; 
[profile release]; 
} 

@CodaFi 아무것도를, 즉 자신의 UIViewController 하위의 이름 인 경우.

+0

발신자는 실제로 내가 tableview를 추가 한보기 컨트롤러입니다. tableview에는 사용자 정의 tableview 셀이 있으며이 셀에는이 코드에 대한 코드가 호출됩니다. 그래서 당신의 대답은 UIViewcontroller에 UIButton이 존재하지 않고 UITableviewCell에 존재하므로 보류하지 않을 것입니다. – pankaj

관련 문제