swift - How modularize and reuse parts of the view and controller? -
i have view navigation bar, buttons, , actions associated them example. there way package parts of view , controller can drag , drop other views along code? , of course maintain code in single place changes reflect in pages using it.
is possible creating framework , super classes can shared across project , other projects? not sure packaging ui view components too. experience or direction appreciated!
this pet peeve of mine. asking how modularize , reuse parts of view controller, not view.
uiview , uiviewcontroller in totally different families of objects. referring view controller view causes no end of confusion.
please go , edit subject , question body use correct terms.
edit:
probably cleanest way combine view controllers using container views , embed segues. make each group of components it's own view controller. when want host view controller's content in view controller, follow these steps:
create instance of component view controller in storyboard , configure desired.
drag container view onto hosting view controller , position want it. (remember set constraints gets placed there @ runtime.)
control-drag container view onto component view controller want add module.
when component view controller becomes building block can drop view controller , functions independently. works well, , want, code , views behave unit.
that's pretty it. if want connect hosting view controller , component view controller can add code in hosting view controller's prepareforsegue method sets hosting view controller delegate of component view controller, , can save pointer component view controller can send messages later if need to.
Comments
Post a Comment