日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

你真的会用storyboard开发吗?

發(fā)布時(shí)間:2023/12/15 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 你真的会用storyboard开发吗? 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

2019獨(dú)角獸企業(yè)重金招聘Python工程師標(biāo)準(zhǔn)>>>

在一般的布局中,我們先使用一個(gè)plist文件,做為tabbarVC的的4個(gè)選項(xiàng) pilist文件如下 然后創(chuàng)建多個(gè)Storyboard,以及Storyboard關(guān)聯(lián)的文件, 然后刪除啟動(dòng)的一些sb界面,讓界面啟動(dòng)時(shí)候從AppDelegate中啟動(dòng), 在AppDelegate中寫下如下代碼

<!-- lang: cpp --> - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch.self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; self.window.backgroundColor = [UIColor whiteColor]; //b不要在主方法中寫碎代碼 [self setUI]; [self.window makeKeyAndVisible]; return YES;

}

-(void)setUI{

UITabBarController *uiTabBar = [[UITabBarController alloc] init];NSURL *url = [[NSBundle mainBundle] URLForResource:@"MainUI" withExtension:@"plist"]; NSArray *arr = [NSArray arrayWithContentsOfURL:url];for (NSDictionary *dic in arr) {UIStoryboard *sb = [UIStoryboard storyboardWithName:dic[@"vcName"] bundle:nil];UIViewController *uiVC = sb.instantiateInitialViewController;uiVC.title = dic[@"title"];uiVC.tabBarItem.image = [UIImage imageNamed:dic[@"icon"]];uiVC.tabBarItem.badgeValue = dic[@"badgeNumber"];[uiTabBar addChildViewController:uiVC]; }self.window.rootViewController = uiTabBar;

}

然后就能看到如下功能了,

效果如下

那在SB文件中的按鈕點(diǎn)擊跳轉(zhuǎn)到其他SB文件中怎么處理呢?如下代碼:

<!-- lang: cpp -->
  • (IBAction)clickBtn:(id)sender { UIStoryboard *sb = [UIStoryboard storyboardWithName:@"hhh" bundle:nil]; UIViewController *vc = sb.instantiateInitialViewController; [self.navigationController pushViewController:vc animated:YES]; }

當(dāng)然我講的肯定不是很清晰,下面你看下我的源代碼吧!嘻嘻,希望對(duì)你有用!

下面是我在gitthub上詳細(xì)地址:https://github.com/pyawkk/SB-.git

轉(zhuǎn)載于:https://my.oschina.net/panyong/blog/372385

總結(jié)

以上是生活随笔為你收集整理的你真的会用storyboard开发吗?的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。