一、创建IOS基础模板
1.安装软件
开发工具:XCode 调试工具:Simulatior
2.创建项目
3.删除界面设计相关模板
4.删除info相关设置
5.删除AppDelegate.m中的多余的默认代码
6.通用AppDelegate代码
AppDelegate.h
#import <UIKit/UIKit.h>
#import "ViewController.h"
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (nonatomic,strong) UIWindow *window;
@property (nonatomic,strong) UINavigationController *naviController;
@property (nonatomic,strong) ViewController *viewController;
@end
AppDelegate.m
#import "AppDelegate.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
//1.系统创建UIWindow
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
//2.将UIWindow设置为程序主窗口,一个应用程序只能有一个主窗口
[self.window makeKeyAndVisible];
//创建一个新窗口
self.viewController = [[ViewController alloc] init];
//创建一个导航控制器,并将导航控制器放在View控制器上
UINavigationController *navi = [[UINavigationController alloc] initWithRootViewController:self.viewController];
//将导航控制器作为根页面展示
self.window.rootViewController = navi;
return YES;
}
@end
7.创建对应的viewController,设置属性
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor redColor];
// Do any additional setup after loading the view.
}
@end
8.运行,调试
二、使用cocoaPods管理第三方库
1.在项目根目录下创建Podfile文件
2.Podfile文件中写入需要导入的库信息
platform :ios, '9.0'
target 'Demo9_entry' do
use_frameworks!
#网络库
pod 'AFNetworking'
#下拉刷新,上拉加载更多
pod 'MJRefresh'
#图片缓存库
pod 'SDWebImage'
# 字典/模型互转
pod 'Mantle'
# 自动布局
pod 'Masonry'
end
3.打开终端,切入项目根目录中,执行命令“pod install”
4.关闭当前项目,使用新的启动文件