私のアプリでは、Collectionview セル内の画像を解析しました。これは、大きな画像で別の画面に押したときにセグエになります。これはうまくいきます。しかし、文字列の配列を含むラベルを同じ宛先ビューコントローラーに追加しようとすると、次のようになります。
キャッチされていない例外 'NSInvalidArgumentException' が原因でアプリを終了しています。理由: '-[__NSCFString objectAtIndex:]: 認識されないセレクターがインスタンス 0xaaa7520 に送信されました'
各配列、画像、および文字列には、同じ量のインデックスがあります。
最初のView Controllerで
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"BottomSegue"]) {
//DetailShowImageViewController *detailedVC = segue.destinationViewController;
//detailedVC.detailImageView =sender;
NSArray *indexPaths = [self.bottomCollectionview indexPathsForSelectedItems];
NSLog(@"%@", indexPaths);
BottomCollectionDetail *destinationVC =segue.destinationViewController;
NSIndexPath *indexPath = [indexPaths objectAtIndex:0];
NSLog(@"%@", indexPath);
destinationVC.imageFromArray = [bottomArray objectAtIndex:indexPath.row];
destinationVC.string = [arrayOfTitles objectAtIndex:indexPath.row];
[self.bottomCollectionview deselectItemAtIndexPath:indexPath animated:YES];
}
宛先VC.h
@property (weak, nonatomic) IBOutlet UILabel *labelOne;
@property (weak, nonatomic) IBOutlet UIImageView *imageViewBCD;
@property(weak, nonatomic) NSString *string;
@property(weak, nonatomic)UIImage *imageFromArray;
目的地VC.m
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
self.imageViewBCD.image = _imageFromArray;
self.labelOne.text = _string; //This is the line of code that is causing exception
}
私の問題は、例外をスローしている文字列を表示するラベルを取得しようとしています。とにかくこれを修正できますか?