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
Post a Comment