objective c - Design one XIB and re-use it in different UIViewControllers -


i have 1 uiview want use in every of uiviewcontrollers. main ui designed storyboard. uiview has own xib.

so don't want put ui of uiview hand every uiviewcontroller, , connect outlets on every uiviewcontroller. thought maybe possible create ui, , connections in 1 xib , somehow reuse it. possible? if yes how?

just add line viewcontrollers have reference custom view:

yourview *yourview = (yourview *)[[nsbundle mainbundle] loadnibnamed:@"yourxib"                                                                owner:self                                                              options:nil].firstobject; 

but since want custom view in of viewcontrollers, recommend having 1 uiviewcontroller subclass contains line above, subclass uiviewcontroller each additional 1 in project. way you'll have reference custom view in each viewcontroller, have write line once.


Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -