简体   繁体   中英

iOS - Shared View in different View Controllers

I need to add shared view (analogue of TabBar, custom menu) to few ViewControllers. I'm going to use Singletone:

static BottomBarMenu *sharedBottomBarMenu = nil;

+ (BottomBarMenu *)sharedBottomBarMenu
{
static dispatch_once_t once_token = 0;
dispatch_once(&once_token, ^{
    sharedBottomBarMenu =  [[BottomBarMenu  alloc] init];
    [self setupMenu];
});

return sharedBottomBarMenu;
}

, where setupMenu is customization method (background, button images, etc.)

How should I connect my UIView class to different View Controllers? I've realized interface on Storyboard.

You can't share a single view between view controllers. A view can only be a subview of a single view.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM