search

Home  >  Q&A  >  body text

ios - 输入人数后如何改变image

![图片上传中...]

问题是这样的:点击cell 然后cell的图片会改变,同时吧image设置成可以交互的状态,然后增加了alert对话框,这些都没问题,但是我需要在输入数字之后改变image的图片,这个应该怎么去实现?

PHPzPHPz2889 days ago322

reply all(6)I'll reply

  • 黄舟

    黄舟2017-04-17 17:54:12

    You should be using UICollectionView. The image of each Cell should be set in the cellForItemAtIndexPath callback according to the Model data (such as imagePath) corresponding to the Cell. After you change the number through the Alert dialog box, you can modify the corresponding data of the Cell (imagePath and the like) in the response method of AlertAction, and then reloadData.

    Another idea is that when you click on the Cell, you can get the indexPath of the Cell. Then after you change the number through the Alert dialog box, you can take this indexPath in the response method of AlertAction to call cellForItemAtIndexPath to get the Cell. Then just take this Cell object and modify its image.

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 17:54:12

    The callback method setImage is determined at the alert point

    reply
    0
  • 怪我咯

    怪我咯2017-04-17 17:54:12

    Write a protocol in the cell to call back the view controller

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 17:54:12

    Set in AlertAction BLOCK

    reply
    0
  • 迷茫

    迷茫2017-04-17 17:54:12

    ReloadData() directly after setting the data, this is the simplest

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 17:54:12

    After the setting is completed, just use the reload method. This function can be implemented by customizing the Delegate through the proxy or using a block. Of course, notifications are also available. It just tells the view that the event needs to be reloaded

    reply
    0
  • Cancelreply