nib但没有获得UICollectionView IOS7

时间:2014-05-23 10:10:24

标签: ios uicollectionview uicollectionviewcell

您好我的应用程序中有UICollectionView我正在使用JSON从服务器显示图像。现在我在点击UICollectionViewCell之类的时候试图在detailViewController中显示图像时出现错误。

2014-05-23 15:27:55.097 filcker[1836:70b] *** Assertion failure in-[detailimagepoliticalViewController loadView], /SourceCache/UIKit_Sim/UIKit-2903.23      /UICollectionViewController.m:166
2014-05-23 15:27:55.098 filcker[1836:70b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UICollectionViewController loadView] loaded the "tuG-0Q-NNM-view-150-NJ-MMy" nib but didn't get a UICollectionView.'

我收到以上错误,但我已经将数据源和委托方法连接到UICollectionView。

#import <UIKit/UIKit.h>
#import "imggpolitical.h"
#import "detailimagepoliticalViewController.h"
  @interface imagepoliticalViewController : UIViewController<UICollectionViewDelegate,UICollectionViewDataSource>

  @property (strong, nonatomic) IBOutlet UICollectionView *collectionview;

在prepareForSegue中,我的编码是这样的。

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{

if([segue.identifier isEqualToString:@"photoview"]){
   imggpolitical *cell = (imggpolitical *)sender;
    NSIndexPath *indexPath = [self.collectionview indexPathForCell:cell];

    detailimagepoliticalViewController *idvc =(detailimagepoliticalViewController *)[segue destinationViewController];
    idvc.img = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",[photoids objectAtIndex:indexPath.row]]]]];       
   }

  }

UICollection Code。

 -(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
 {
    return [photoids count];
 }
- (NSInteger)numberOfSectionsInCollectionView: (UICollectionView *)collectionView
{
    return 1;
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{


   static NSString *cellIdentifier =@"Cell";


  imggpolitical *cell=(imggpolitical *) [collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath: indexPath];


  cell.imageview.image=[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",[photoids objectAtIndex:indexPath.row]]]]];

  return cell;
}

这是我已经完成的步骤,但它不起作用请告诉我如何解决这个问题。

感谢。

0 个答案:

没有答案