<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                ## 一:簡單介紹 這是新浪微博的iOS端項目,來自于黑馬的一個實戰項目。(本人沒有培訓,純屬自學,但人要學會感恩,雖然是自己買的學習資料,但是飲水思源!!) 主要分成五大模塊,本次全部運用純代碼實現,其中會用到很多前面學過得內容,如果有的地方有重復的知識點,說明這個知識點真的很重要,沒有時間看視頻學習或者培訓的朋友們,可以看貓貓的這一系列博客,貓貓會竭盡所能的完善他。 有什么不全面的地方,歡迎大家回復我,貓貓會盡快改正的。 ## 二:建立項目導入素材 第一步首先我們要建立我們的項目了,在這兒我并沒有用最新版的xcode6,而是用的xcode5.1,為什么用的5.1而不是6呢? 首先:我所學習的視頻是用的xcode5.1,這是最主要的原因,貓貓作為一個體育生,自學編程兩年所得到的經驗就是,在看視頻自學的時候盡可能讓自己的一切與別人實體教學一樣,貓貓曾經在學android時候就因為android 的sdk不一樣,新出的碎片化跟視頻中的操作不一樣而大大打擊學習的積極性。 其次:企業還有很多再用5.1甚至是4.1(據朋友說。。。)當然,這個也可以看出主要原因啦。不過貓貓建議,在學到一定水平的時候,多接收下新的知識,當然我覺得舊的更重要,不說咱國語有云,溫故知新,萬變不離其宗,學扎實舊的知識,新的知識上手搜easy。 建立項目 選擇Single View Application 選擇下一步? ![](https://box.kancloud.cn/2016-01-20_569f1d959e00a.jpg) 寫入項目名稱貓貓微博(名字隨便) 選擇下一步? ![](https://box.kancloud.cn/2016-01-20_569f1d95c636b.jpg)? 然后就是下一步下一步了 因為我們要用純代碼,所以先刪除其他沒用的Controller還有Main.storyboard? ![](https://box.kancloud.cn/2016-01-20_569f1d95e47b3.jpg) Remove References 表示只是在xcode中刪除,但是在文件中還有。? Move To Trash 就代表,直接進入了系統廢紙簍了? ![](https://box.kancloud.cn/2016-01-20_569f1d960b3a5.jpg) 然后導入素材(我們用到的圖片) images.xcassets? ![](https://box.kancloud.cn/2016-01-20_569f1d961d361.jpg)? applcon里面的是在手機首頁的那個圖? launchimage是指得應用加載時候開始的那個圖片? ![](https://box.kancloud.cn/2016-01-20_569f1d9637323.jpg) ![](https://box.kancloud.cn/2016-01-20_569f1d9650f6a.jpg)? 對于第一個圖片的空白位置,我們可以直接通過修改json文件來控制,當然,直接拖拽進去也可以(相當于修改json)? ![](https://box.kancloud.cn/2016-01-20_569f1d966aec0.jpg) ## 三:創建window 前面有博客寫過程序運行時候會經過哪些步驟。? 因為我們刪除了Main.storyboard,這時候運行程序會報錯,我們需要修改圖里面的main 刪除他,改成空? ![](https://box.kancloud.cn/2016-01-20_569f1d9680c4b.jpg) 這時候運行程序,將會是這樣:? ![](https://box.kancloud.cn/2016-01-20_569f1d96ae0e9.jpg)? 烏七八黑。。。 然后我們要在NYAppDelegate.m來寫代碼了。 ~~~ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { //1.創建窗口 self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds]; //2.設置根控制器 NYTabBarViewController *tabbarC = [[NYTabBarViewController alloc] init]; self.window.rootViewController = tabbarC; //3.顯示窗口 [self.window makeKeyAndVisible]; return YES; } ~~~ 簡單三步,就可以顯示了。? 自己寫NYTabBarViewController.m ~~~ // // NYTabBarViewController.m // 貓貓微博 // // Created by apple on 15-6-2. // Copyright (c) 2015年 znycat. All rights reserved. // #import "NYTabBarViewController.h" #import "NYHomeViewController.h" #import "NYMessageCenterViewController.h" #import "NYDiscoverViewController.h" #import "NYProfileViewController.h" #import "NYNavigationController.h" @interface NYTabBarViewController () @end @implementation NYTabBarViewController -(void)viewDidLoad { [super viewDidLoad]; // 1.初始化子控制器 // 1.初始化子控制器 NYHomeViewController *home = [[NYHomeViewController alloc] init]; [self addChildVc:home title:@"首頁" image:@"tabbar_home" selectedImage:@"tabbar_home_selected"]; NYMessageCenterViewController *messageCenter = [[NYMessageCenterViewController alloc] init]; [self addChildVc:messageCenter title:@"消息" image:@"tabbar_message_center" selectedImage:@"tabbar_message_center_selected"]; NYDiscoverViewController *discover = [[NYDiscoverViewController alloc] init]; [self addChildVc:discover title:@"發現" image:@"tabbar_discover" selectedImage:@"tabbar_discover_selected"]; NYProfileViewController *profile = [[NYProfileViewController alloc] init]; [self addChildVc:profile title:@"我" image:@"tabbar_profile" selectedImage:@"tabbar_profile_selected"]; } /** * 添加一個子控制器 * * @param childVc 子控制器 * @param title 標題 * @param image 圖片 * @param selectedImage 選中的圖片 */ - (void)addChildVc:(UIViewController *)childVc title:(NSString *)title image:(NSString *)image selectedImage:(NSString *)selectedImage { // 設置子控制器的文字 childVc.title = title; // 同時設置tabbar和navigationBar的文字 // childVc.tabBarItem.title = title; // 設置tabbar的文字 // childVc.navigationItem.title = title; // 設置navigationBar的文字 // 設置子控制器的圖片 childVc.tabBarItem.image = [UIImage imageNamed:image]; childVc.tabBarItem.selectedImage = [[UIImage imageNamed:selectedImage]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]; // 設置文字的樣式 NSMutableDictionary *textAttrs = [NSMutableDictionary dictionary]; textAttrs[NSForegroundColorAttributeName] = NYColor(123, 123, 123); NSMutableDictionary *selectTextAttrs = [NSMutableDictionary dictionary]; selectTextAttrs[NSForegroundColorAttributeName] = [UIColor orangeColor]; [childVc.tabBarItem setTitleTextAttributes:textAttrs forState:UIControlStateNormal]; [childVc.tabBarItem setTitleTextAttributes:selectTextAttrs forState:UIControlStateSelected]; // 先給外面傳進來的小控制器 包裝 一個導航控制器 NYNavigationController *nav = [[NYNavigationController alloc] initWithRootViewController:childVc]; // 添加為子控制器 [self addChildViewController:nav]; } /* #pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller. } */ @end ~~~ 這里用到了面向對象的思路來設計代碼,我們需要一個NYTabBarViewController,要創建他,誰最清楚呢?當然是他自己了,所以我們就把代碼放到他自己里面。做好代碼的重構。 而對于? “NYHomeViewController.h”? “NYMessageCenterViewController.h”? “NYDiscoverViewController.h”? “NYProfileViewController.h”? “NYNavigationController.h”? 這些,大家先把他看做是tableViewController或者ViewController就可以了,就是一個個的類,還沒有實現功能。 效果就是這樣:? ![](https://box.kancloud.cn/2016-01-20_569f1d96bec8f.jpg)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看