我目前的问题是我无法在表格 View Controller B 中显示多于一张照片。
我尝试使用数组来存储照片 URL,但是当我选择第一张照片时,我的数组只能存储一个 URL。当我选择另一张照片时,我的数组只会将第一个 url 替换为第二个,而第一个 url 消失了。下面是我的代码,这个问题是从这个 question 扩展而来的
- (IBAction)organiseAttachement:(id)sender {
// Initialize View Controller
PhotosListViewController *photoListViewController = [[PhotosListViewController alloc]initWithNibName:@"PhotosListViewController" bundle:nil];
photoListViewController.test = imageURL;
collector = [[NSMutableArray alloc]initWithCapacity:0];
[self.collector addObject:imageURL];
NSLog(@"Collector in root %@",self.collector);
[self.navigationController pushViewController:photoListViewController animated:YES];
}
最佳答案
您正在方法内初始化数组。因此,每次单击按钮时,数组都会被初始化。这就是为什么你的第一个网址丢失了。因此,将数组初始化保持在此方法之外。
collector = [[NSMutableArray alloc] init];
关于ios - 将从图库中选择的照片显示到表格 View 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17337924/