2014-09-01 5 views
0

collectionViewCell을 두드릴 때 UITableViewController을 표시하려고합니다. didSelectItemAtIndexPath를 사용하여이 작업을 수행했습니다. collectionView를 누를 때 아무 일도 일어나지 않고 UI를 눌렀을 때 차단되고 아무 것도 할 수 없습니다. 오류/로그 메시지가 표시되지 않습니다. 왜 viewController를 제시하지 않고 왜 오류 메시지가 표시되지 않습니까?UITableViewController 블록 제시 UI

있는 UITableViewController 인터페이스 빌더는 :

enter image description here

-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath 
{ 
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; 

    HomeProfileViewController *hpvc = [storyboard instantiateViewControllerWithIdentifier:@"NavProfile"]; 

    hpvc.idString= [[homesDic objectAtIndex:indexPath.item] objectForKey:@"idString"]; 
    hpvc.imageArray = [[NSMutableArray alloc]init]; 
    hpvc.imageArray = [imageDic objectAtIndex:indexPath.item]; 

    [self presentViewController:hpvc animated:YES completion:nil]; 
} 
+0

왜 두 번'hpvc.imageArray ='입니까? –

답변

0

내 추측은 스토리 보드로드 시간이 걸리는 것입니다. 인스턴스 레벨 storyBoard 객체를 유지하고 didSelectItemAtIndexPath에서 게으른 인스턴스화를 수행합니다.

게으른 인스턴스화 코드 :

- (UIStoryboard *)storyboard: { 
    if (!_storyboard) { 
     _storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; 
    } 
    return _storyboard; 
} 

그리고 당신의 didSelectItemAtIndexPath에서

,
UIStoryboard *storyboard = [self storyboard]; 

는 다시, 이것은 나의 추측이다. 주어진 코드에서만 추론됩니다.