ios - How to edit a UICollectionView item in another UIViewController? -


i'm using master detail view controller swift. when click on master cell, see collection view containing list of pictures. each picture represent data stored inside core data. each picture data has timestamp , picture taken same day stored in same master cell.

[date of day 1]    [pic1]    [pic2]  [date of day 2]    [pic3]    [pic4] 

what want achieve is: when click on picture, viewcontroller displayed (through segue) , new vc allows me edit picture , change date.

the thing have multiple things happening here when change day or picture:

  • if pic alone in collection, have remove master day cell too.
  • if pic not alone, need update detail collection view
  • in cases, if have create new day, need create new master cell , update view , if need delete day, have update master view.

if edit collection items, can a:

self.collectionview performbatchupdates: 

and update model, , notify collection view of action... don't see how can uiviewcontroller.

currently, in edit view controller, update model , dismiss view controller. , crash because collectionview tries display item not part of current collection anymore...

to solve issue, maybe can use protocol in order inform detail view edit view if that, need give indexpath of edit cell edit view , give detail view through protocol... why not. not clean in opinion.

another problem is, app seems crash in master view when delete day. because, master view doesn't know deleted day edit view.

my main problem don't see how tell master view controller made model changes... when don't have indexpath information within edit view.

technically, use notificationcenter notify both views, guess... still, need pass both indexpath master view detail view , edit view.

ugly.

several ways can achieved:

1) delegation: view controller containing collection view act delegate of edit view controller , when editing done callback method 'the view controller containing collection view'

2) notification: editingfinished

3) blocks


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

Kivy: Swiping (Carousel & ScreenManager) -