Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/117.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 正在尝试将字符串数组传递给目标视图控制器_Ios_Arrays_String_Segue - Fatal编程技术网

Ios 正在尝试将字符串数组传递给目标视图控制器

Ios 正在尝试将字符串数组传递给目标视图控制器,ios,arrays,string,segue,Ios,Arrays,String,Segue,在我的应用程序中,我对Collectionview单元格中的图像进行了解析,当按下该单元格到另一个图像较大的屏幕时,这些单元格会继续显示。这个很好用。但是,当我尝试将包含字符串数组的标签添加到同一目标视图控制器时,我得到: 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“-[\uu NSCFString objectAtIndex:]:发送到实例0xaaa7520的选择器无法识别” 每个数组、图像和字符串都有相同数量的索引 第一视图控制器 -(vo

在我的应用程序中,我对Collectionview单元格中的图像进行了解析,当按下该单元格到另一个图像较大的屏幕时,这些单元格会继续显示。这个很好用。但是,当我尝试将包含字符串数组的标签添加到同一目标视图控制器时,我得到:

由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“-[\uu NSCFString objectAtIndex:]:发送到实例0xaaa7520的选择器无法识别”

每个数组、图像和字符串都有相同数量的索引

第一视图控制器

-(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];


}
目的地

@property (weak, nonatomic) IBOutlet UILabel *labelOne;
@property (weak, nonatomic) IBOutlet UIImageView *imageViewBCD;
@property(weak, nonatomic) NSString *string;
@property(weak, nonatomic)UIImage *imageFromArray;
目的地

- (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
}

我的问题是试图让标签显示字符串,这就是抛出异常。还有什么我可以解决的吗

检查您的
阵列ftitles
它正在一些地方发布。检查代码的那部分。但您可以尝试使用
strong
属性设置这两个
array

NSInvalidArgumentException',原因:'-[\uu NSCFString objectAtIndex::]:发送到实例0xaaa7520'的未识别选择器非常简单,与释放无关,问题是您的
阵列ftiles
NSString
而不是
NSArray
。检查创建/分配
阵列ftiles

的所有位置
阵列ftiles
的内容是什么?确定标签有问题吗?阵列ftiles包含解析字符串。字符串显示在原始视图控制器的NSLog中。只需尝试此
self.labelOne.text=[NSString stringWithFormat:@“%@”,_string]
您的
arrayOfTitles
是一个NSString而不是NSArrayMade arrayOfTitles一个强属性,但仍然存在绘图异常。您是否在添加对象的位置检查了数组,尝试以下操作:将所有对象添加到数组中时,在使用日志检查后,也可以尝试使用ViewWillExample而不是ViewDidLoad。对象已就位。问题似乎出在prepareForSegue方法中