@implementation StudyViewController
- (void)viewDidLoad {
[super viewDidLoad];
//[super viewWillAppear:animated];
顯示設置uimages的...... 基本上我通過afnetworking收到responseobject。 然後將數據存儲在稱爲arData不能在uicollectionview
............
...........
[manager POST:studysearchUrl parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
[MBProgressHUD hideHUDForView:self.view animated:YES];
NSLog(@"%@",responseObject);
[Global sharedGlobal].arrData = responseObject;
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
[MBProgressHUD hideHUDForView:self.view animated:YES];
NSLog(@"Error: %@", error);
}];
全局定義的nsmutable陣列}
#pragma collection view methods
- (NSInteger) numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
return 1;
}
-(NSInteger) collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
return [[[Global sharedGlobal]arrData] count];
}
-(UICollectionView *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"StudyCell" forIndexPath:indexPath];
然後nsmutable對象索引被存儲爲字典而創建圖像路徑來訪問。 我需要從這個nsmutable數組中提取3組數據(firstUID,second,third),它將傳遞給NSURL來構造圖像url路徑,如下所示。 其餘參數(超文本,UrlKey,portNumber,分隔符)通過nsdictionary傳遞(這裏未顯示)。
UIImageView *img = (UIImageView *)[cell viewWithTag:1000];
NSDictionary *dictionary = [Global sharedGlobal].arrData[indexPath.row];
img.imageURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@%@%@?parametersintheWebServer&firstID=%@&secondID=%@&thirdID=%@",hyperText, UrlKey, portNumber, seperator, [Global sharedGlobal].arrData[indexPath.row] [@"firstUID"],[Global sharedGlobal].arrData[indexPath.row][@"secondUID"],[Global sharedGlobal].arrData[indexPath.row][@"thirdUID"]]];
return cell;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
1 - 我似乎無法進去
-(UICollectionView *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
2-在控制檯中的NSLog輸出任何東西,我不能顯示任何圖像,即使我知道從Web服務接收到的參數是否正確( &我的NSLog他們沒有任何問題,當viewDidLoad中。
任何幫助,將不勝感激。
謝謝。
檢查你的共享控制器是否存在? – Wain 2015-02-23 18:57:13
arrData nsmutable在Global.h中定義&它存在於這個視圖中controllerStudyViewController – 2015-02-24 01:17:23