单击单元格到详细信息视图时,Segue会导致断点

时间:2013-09-03 15:05:41

标签: objective-c segue

单击集合视图中的单元格会在单击时生成断点,以在详细视图中显示较大的图像。单元格按原样显示图像,但细节视图不显示图像。如果您需要更多信息,请告诉我。提供的线索是。 (lldb)

    {
    @autoreleasepool {
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); [BREAKPOINT]
    }
}                                                                                                                                                                                                       The code that generates the cell information and passes through the segue.                           

    - (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath;
{
    // code for the custom cell created:


    Cell *cell = [cv dequeueReusableCellWithReuseIdentifier:kCellID_Biffy forIndexPath:indexPath];

    // load  image
    NSString *imageToLoad_Biffy = [NSString stringWithFormat:@"%d_Biffy.jpg", indexPath.row];
    cell.image.image = [UIImage imageNamed:imageToLoad_Biffy];



    return cell;
}


- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([[segue identifier] isEqualToString:@"showDetail_biffy"])
    {
        NSIndexPath *selectedIndexPath = [[self.collectionView indexPathsForSelectedItems] objectAtIndex:0];

        // loads the image 

        NSString *imageNameToLoad = [NSString stringWithFormat:@"%d_Biffy", selectedIndexPath.row];
        NSString *pathToImage = [[NSBundle mainBundle] pathForResource:imageNameToLoad ofType:@"jpg"];
        UIImage *image2 = [[UIImage alloc] initWithContentsOfFile:pathToImage];
;

        Detail_ViewController_Biffy *detailViewController = [segue destinationViewController];
       detailViewController.image2 = image2;

    }
}     NEW CODE:  

@interface Detail_ViewController_Biffy ()


@property (strong, nonatomic) IBOutlet UIImageView *images;


@end

@implementation Detail_ViewController_Biffy

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.images.image = self.image2;  <------yellow sign Incompatible pointer types assigning to UIImage from Ui IMageview


}

@end

1 个答案:

答案 0 :(得分:1)

你说的错误是:
( setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key image.')

假设你使用故事板,我认为你做了以下事情之一:

  • 修改了与IBOutlets的连接(当然是您的形象)
  • 重命名了一个属性
  • 从代码中删除了一个属性而未删除情节提要中的连接
  • 为您的某个视图控制器指定的类与您在代码中使用的类不同
  • 仔细检查故事板和代码之间的一致性!我希望它有所帮助!