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

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

你真的会用storyboard开发吗?

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

2019獨角獸企業重金招聘Python工程師標準>>>

在一般的布局中,我們先使用一個plist文件,做為tabbarVC的的4個選項 pilist文件如下 然后創建多個Storyboard,以及Storyboard關聯的文件, 然后刪除啟動的一些sb界面,讓界面啟動時候從AppDelegate中啟動, 在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文件中的按鈕點擊跳轉到其他SB文件中怎么處理呢?如下代碼:

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

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

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

轉載于:https://my.oschina.net/panyong/blog/372385

總結

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

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。