21. iOS应用框架(上)
主要讲解了 Project 文件目录整理分类,Storyboard 和代码结合使用,Constraints 的使用。稍后在项目里面实践一下。
有提到 [UIScreen mainScreen].bounds 的问题。
我之前就研究过,见:http://gewill.org/2015/08/04/UIScreen-mainScreen-bounds-in-Xcode-7-Beta-4/
23. iOS应用框架(下)
主要演示 Storyboard 的自动布局和代码管理跳转和动画过度。但是总感觉有点基本上是在 AppDelegate 中管理 Storyboard 的跳转关系,实不如 Storyboard references 清晰明了,且不妨碍分工开发。
代码如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) UINavigationController *loginNavigationVC;
- (void)loadLoginView;
- (void)loadMainView;
@end
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
|
#import "AppDelegate.h" #import "BLUserInfoViewController.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
- (void)loadLoginView { UIStoryboard *loginStoryboard = [UIStoryboard storyboardWithName:@"Login" bundle:[NSBundle mainBundle]]; self.loginNavigationVC = loginStoryboard.instantiateInitialViewController; self.window.rootViewController = self.loginNavigationVC; }
- (void)loadMainView { UIStoryboard *userInfoStoryboard = [UIStoryboard storyboardWithName:@"UserInfo" bundle:[NSBundle mainBundle]]; BLUserInfoViewController *userInfoVC = [userInfoStoryboard instantiateViewControllerWithIdentifier:@"BLUserInfoViewController"]; UINavigationController *navc = [[UINavigationController alloc] initWithRootViewController:userInfoVC]; navc.tabBarItem.title = @"userInfo"; UITabBarController *tabBarC = [[UITabBarController alloc] init]; tabBarC.viewControllers = @[navc]; self.window.rootViewController = tabBarC; [self.window addSubview:self.loginNavigationVC.view]; [UIView animateWithDuration:0.3 animations:^{ self.loginNavigationVC.view.alpha = 0; self.loginNavigationVC.view.frame = CGRectZero; self.loginNavigationVC.view.transform = CGAffineTransformMakeScale(0.1, 0.1); } completion:^(BOOL finished) { self.loginNavigationVC = nil; }]; }
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; self.window.backgroundColor = [UIColor whiteColor]; [self.window makeKeyAndVisible]; [self loadLoginView]; return YES; }
- (void)applicationWillResignActive:(UIApplication *)application { }
- (void)applicationDidEnterBackground:(UIApplication *)application { }
- (void)applicationWillEnterForeground:(UIApplication *)application { }
- (void)applicationDidBecomeActive:(UIApplication *)application { }
- (void)applicationWillTerminate:(UIApplication *)application { }
@end
|