[英]How can I display selected images from the Photo Library or Camera in a CollectionView? Gallery view
[英]Display Photo Selected From Gallery into Table View
我目前的問題是我無法在表視圖控制器B中顯示多張照片。我嘗試使用數組來存儲照片URL,但是當我選擇第一張照片時,我的數組只能存儲一個URL。 當我選擇另一張照片時,我的陣列只會將第一個網址替換為第二個網址,第一個網址就會消失。 下面是我的代碼,這個問題是從這個問題延伸出來的
- (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];
在此函數之外初始化數組。 在viewDidLoad方法中初始化。 那對你來說最好。
collector = [[NSMutableArray alloc]init];
您正在初始化方法內的數組。 所以每次單擊按鈕,數組都會被初始化。 這就是你的第一個網址丟失的原因。 因此,在此方法之外保持數組初始化
collector = [[NSMutableArray alloc] init];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.