2012-01-12 2 views
1

didSelectRowAtIndexPath에 문제가 있습니다.이 지점에 다른 쿼리가 있지만 아무 것도 내 문제를 해결하지 못하는 것 같습니다. 기본적으로 테이블 뷰가로드되지만 셀을 클릭하면 아무 것도하지 않습니다. 즉, 새 xib를 누르지 마십시오. 어떤 도움이라도 좋을 것입니다.didSelectRowAtIndexPath가 새보기를 푸시하지 않음

@implementation ViewController 
@synthesize TableViewControl; 
@synthesize tableList; 

#pragma mark - View lifecycle 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 

    self.title = @"The Bird Watching App"; 
    // Do any additional setup after loading the view, typically from a nib. 


    tableList = [[NSMutableArray alloc] initWithObjects:@"Map",@"My Profile",@"Bird Info", nil]; 



    TableViewControl.dataSource = self; 
    TableViewControl.delegate = self; 

} 

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

    [tableView deselectRowAtIndexPath:indexPath animated:YES]; 

    if ([[ tableList objectAtIndex:indexPath.row] isEqual:@"Map"]) 
    { 
     Map *map = [[Map alloc] initWithNibName:@"Map" bundle:nil]; 
     [self.navigationController pushViewController:map animated:YES]; 

    } 

    else if ([[ tableList objectAtIndex:indexPath.row] isEqual:@"My Profile"]) 
    { 
     MyProfile *myprofile = [[MyProfile alloc] initWithNibName:@"My Profile" bundle:nil]; 
     [self.navigationController pushViewController:myprofile animated:YES]; 
    } 

    else if ([[ tableList objectAtIndex:indexPath.row] isEqual:@"Bird Info"]) 
    { 
     BirdInfo *birdinfo = [[BirdInfo alloc] initWithNibName:@"Bird Info" bundle:nil]; 
     [self.navigationController pushViewController:birdinfo animated:YES]; 
    } 

}  


@end  

답변

2

NSStringisEqual:에있어서 포인터 비교 문자열의 실제 내용 사이의 비교를 수행하지. if 문은 isEqualToString:을 사용하여 적절한 비교를 수행해야합니다.

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

    [tableView deselectRowAtIndexPath:indexPath animated:YES]; 

    if ([[ tableList objectAtIndex:indexPath.row] isEqualToString:@"Map"]) 
    { 
     Map *map = [[Map alloc] initWithNibName:@"Map" bundle:nil]; 
     [self.navigationController pushViewController:map animated:YES]; 

    } 

    else if ([[ tableList objectAtIndex:indexPath.row] isEqualToString:@"My Profile"]) 
    { 
     MyProfile *myprofile = [[MyProfile alloc] initWithNibName:@"My Profile" bundle:nil]; 
     [self.navigationController pushViewController:myprofile animated:YES]; 
    } 

    else if ([[ tableList objectAtIndex:indexPath.row] isEqualToString:@"Bird Info"]) 
    { 
     BirdInfo *birdinfo = [[BirdInfo alloc] initWithNibName:@"Bird Info" bundle:nil]; 
     [self.navigationController pushViewController:birdinfo animated:YES]; 
    } 

} 
+0

답장을 보내 주셔서 감사합니다. 그냥 시도했지만 여전히 동일한 문제 : ( – Lateralus

+0

'self.navigationController'가 nil이 아님을 확인할 수 있습니까? –

+0

게시 한 내용을 복사하여 모든 self.navigationController 다음에 pushViewController가옵니다. – Lateralus

관련 문제