Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2014
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.79 KB | None | 0 0
  1. - (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view
  2. {
  3.  
  4. myArray = [[NSMutableArray alloc] init];
  5.  
  6.  
  7. //create new view if no view is available for recycling
  8.  
  9. // view = [[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 250.0f, 300.0f)] autorelease];
  10.  
  11. FXImageView *imageView = [[[FXImageView alloc] initWithFrame:CGRectMake(0, 0, 250.0f, 350.0f)] autorelease];
  12. imageView.contentMode = UIViewContentModeScaleAspectFit;
  13. imageView.asynchronous = YES;
  14. // imageView.reflectionScale = 0.5f;
  15. // imageView.reflectionAlpha = 0.25f;
  16. // imageView.reflectionGap = 10.0f;
  17. imageView.shadowOffset = CGSizeMake(0.0f, 2.0f);
  18. imageView.shadowBlur = 5.0f;
  19. imageView.cornerRadius = 10.0f;
  20. view = imageView;
  21.  
  22. [ProgressHUD dismiss];
  23.  
  24. NSString *string1 = [[NSUserDefaults standardUserDefaults] stringForKey:@"Class"];
  25.  
  26. PFQuery *query = [PFQuery queryWithClassName:[NSString stringWithFormat:@"%@",string1]];
  27.  
  28.  
  29. query.cachePolicy = kPFCachePolicyNetworkElseCache;
  30.  
  31. //show loader view
  32.  
  33.  
  34. [query findObjectsInBackgroundWithBlock:^(NSArray *objects, NSError *error) {
  35. if (!error) {
  36.  
  37. myArray = [[NSMutableArray alloc] initWithArray:objects];
  38.  
  39. PFObject *object = [myArray objectAtIndex:index];
  40.  
  41.  
  42. [file getDataInBackgroundWithBlock:^(NSData *data1, NSError *error) {
  43. if (!error) {
  44.  
  45. ((UIImageView *)view).image = [UIImage imageWithData:data1];
  46.  
  47. //[HUD hideUIBlockingIndicator];
  48.  
  49. }
  50. }];
  51.  
  52. }
  53.  
  54. }];
  55.  
  56. return view;
  57.  
  58.  
  59. }
  60.  
  61. - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
  62. {
  63. static NSString *CellIdentifier = @"cell";
  64. UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:CellIdentifier forIndexPath:indexPath];
  65.  
  66. CALayer *layer = cell.layer;
  67. [layer setCornerRadius:8.0f];
  68. [layer setMasksToBounds:YES];
  69. // [layer setBorderWidth:1.0f];
  70. // layer.backgroundColor = [UIColor whiteColor].CGColor;
  71. //can you click
  72.  
  73. PFObject *imageObject = [myArray objectAtIndex:indexPath.item];
  74. PFFile *imageFile = [imageObject objectForKey:@"image"];
  75. NSString *name = [imageObject objectForKey:@"name"];
  76.  
  77. [imageFile getDataInBackgroundWithBlock:^(NSData *data, NSError *error) {
  78. if (!error) {
  79.  
  80. UIImageView *imageView = (UIImageView *)[cell viewWithTag:100];
  81. imageView.image = [UIImage imageWithData:data];
  82.  
  83. UILabel *title2 = (UILabel *)[cell viewWithTag:200];
  84. title2.text = [NSString stringWithFormat:@"%@",name];
  85. title2.font = [UIFont fontWithName:@"GESSTextMedium-Medium" size:12];
  86. }
  87. }];
  88.  
  89.  
  90. return cell;
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement