2014-10-16 3 views
0
이라면 문자열이 비어집니다.

videoURl이라는 NSString 속성을 가진 사용자 정의 셀이 있습니다. 이 상단 모든 것을 URL을 로그온 할 때 내 구현 코드는 괜찮 그러나이didSelectRowAtIndexPath가

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *CellIdentifier = @"RemedyYouTubeTableViewCell"; 
    RemedyYouTubeTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 

    if (cell == nil) { 
     NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"RemedyYouTubeTableViewCell" owner:nil options:nil]; 
     for(id obj in topLevelObjects) { 
      if([obj isKindOfClass:[UITableViewCell class]]) { 
       cell = obj; 
       break; 
      } 
     } 


    } 

    // Configure the cell... 

    cell.videoThumbnail.image = [UIImage imageNamed:[thumbNailArray objectAtIndex:indexPath.row]]; 

    NSString *stringWithoutPng = [[thumbNailArray objectAtIndex:indexPath.row] 
            stringByReplacingOccurrencesOfString:@".png" withString:@""]; 
    cell.titleLabel.text = stringWithoutPng; 
    cell.dateUploadLabel.text = [videoUploadDateArray objectAtIndex:indexPath.row]; 
    cell.durationLabel.text = [videoLengthArray objectAtIndex:indexPath.row]; 
    cell.viewsLabel.text = [videoViewsArray objectAtIndex:indexPath.row]; 
    cell.videoURL = [videoURLArray objectAtIndex:indexPath.row]; 
    NSLog(cell.videoURL); 

    return cell; 
} 

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

    RemedyYouTubeTableViewCell *cell = (RemedyYouTubeTableViewCell *)[self.tableView cellForRowAtIndexPath:indexPath]; 

    NSString *videoURL = cell.videoURL; 
    NSLog(videoURL); 
    NSLog(@"^videourl"); 

    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:videoURL]]; 
} 

처럼 보이는이 바닥 아무 것도 인쇄에서 호출 될 때. 내가 도대체 ​​뭘 잘못하고있는 겁니까? 아니면 더 좋은 방법이 있을까요? 감사!

+1

어떤 세포에 대한,이 전무는 ...이 주어진 코드를 사용하여 didSelectRowAtIndexPath 방법을 교환하십시오? 그렇지 않다면 셀의 레이블에서 텍스트에 액세스 할 수 있습니까? – Yan

+1

didSelectRowAtIndexPath도 호출됩니까? – Paulw11

답변

3

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    videoURL = [videoURLArray objectAtIndex:indexPath.row]; 

    NSLog(videoURL); 

    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:videoURL]]; 
}