关于 ios:collectionView didSelectItemAtIndexPath 与发送图片 | 珊瑚贝

collectionView didSelectItemAtIndexPath with sending images


我正在收藏视图中显示图像。当我选择特定单元格时,详细图像将显示在另一个视图控制器中。委托方法是 didSelectItemAtIndexPath。请帮帮我。

1
2
3
4
5
6
7
8
9
10
11
12
recipeImages = [NSArray arrayWithObjects:@“img2.png”, @“img.png”, @“img1.png”, @“img3.png”, @“img4.png”, @“img5.png”, @“img6.png”, @“img7.png”, nil];

(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView1 cellForItemAtIndexPath:(NSIndexPath *)indexPath{

   static NSString *identifier = @“Cell”;

    CustomCell *cell = (CustomCell *)[collectionView1 dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];

  [cell.imageView setImage:[UIImage imageNamed:[recipeImages objectAtIndex:indexPath.row]]];

    return cell;
}

  • 看看这个问题:stackoverflow.com/questions/21393359/…
  • 请给我详细的代码
  • @Chenna 检查我的答案。它非常简单


检查以下代码:

1
2
3
4
5
6
7
8
(void)collectionView:(UICollectionViewCell *)collectionView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

  {
    DetailViewController *detailVC = [[DetailViewController alloc] initWithNibName:@“MyCell” bundle:[NSBundle mainBundle]];
    detailVC.img= [recipeImages objectAtIndex: indexPath.row];
   [self presentViewController:detailVC animated:YES completion:nil];

  }


检查以下代码:

1
2
3
4
5
6
7
8
9
(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath

    {

      NSString *senderImg=[recipeImages objectAtIndex:indexPath.item];
      NextViewController *next  = [[NextViewController alloc]   initWithNibName:@“NextViewController” bundle:nil];
    next.receivedImage=senderImg;
     [self presentModalViewController:next animated:NO];
      }

NextViewController.h

1
@property(nonatomic,retain)NSString *receivedImage;

NextViewController.m

1
2
3
4
5
6
@syntosize receivedImage;

(void)viewDidLoad
{
   UIImage imageDispay=[UIImage imageNamed:receivedImage];
}


来源:https://www.codenong.com/25720927/

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_9184.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?