storyboard中Modal 的使用

@protocol UIPickerViewDataSource<NSObject>

@required


//有多少列  如果有1列必须实现

- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView;


//每列有多少行

- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component;


//代理方法

@protocol UIPickerViewDelegate<NSObject>

@optional


//返回行的高度

- (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component;


//返回每行显示什么内容

- (nullable NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component;


//自定义View 替换PickerView的行的样式 reusingView次参数没什么作用

- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(nullable UIView *)view;


//pickerView 滚动停止时调用, 获取停止是的数据 都在此方法中

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component;




// 全局刷新pickerView 的数据

- (void)reloadAllComponents;


//单独刷新哪一列的数据

- (void)reloadComponent:(NSInteger)component;


//根据传入的行数,传入的列数, 滚动到那一列的那一行

- (void)selectRow:(NSInteger)row inComponent:(NSInteger)component animated:(BOOL)animated;


//获取当前列的 选中的那一行

- (NSInteger)selectedRowInComponent:(NSInteger)component;




#################### -UITextField-########################################

//属性

@property (nullable, readwrite, strong) UIView *inputView; //键盘View的替换属性

@property (nullable, readwrite, strong) UIView *inputAccessoryView;//附件






#################### -UIToolBar-########################################

//属性

@property(nullable,nonatomic,copy) NSArray<UIBarButtonItem *> *items;//添加多个按钮

@property(null_resettable, nonatomic,strong) UIColor *tintColor;//颜色




#pragma mark - UI进阶02


#################### - UIApplication-########################################


//如何获取当前App 的对象,单例设计模式

[UIApplication sharedApplication];

//属性

@property(nonatomic) NSInteger applicationIconBadgeNumber;//设置app图标的右上角消息角标


// 方法:跳转网页, 跳到其他App 打电话,发短信,发邮件

- (BOOL)openURL:(NSURL*)url



#pragma mark - 程序启动过程


》有storyBoard

1Main函数

2UIApplicationMain函数

3、创建Uiapplication对象和UIapplicationDelegate对象

4UIapplicationDelegate监听APP程序事件

5didFinishLaunchingWithOptions

*系统创建

*创建UIWindow

根据Info.plist文件找到Main.storyboard;

Storyboard 初始化控制器,加载View

View添加到Window上展示

》无storyBoard

1Main函数

2UIApplicationMain函数

3、创建Uiapplication对象和UIapplicationDelegate对象

4UIapplicationDelegate监听APP程序事件

5didFinishLaunchingWithOptions

*didFinishLaunchingWithOptions方法中创建

*创建UIWindow

创建控制器

设置UIWindow的根控制器

设置主窗口并显示


//1.创建window

self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];


//2.创建控制器

ITCViewController *rootVc = [[ITCViewController alloc]init];

targatVc.view.backgroundColor = [UIColor grayColor];

//3.设置rootVC

self.window.rootViewController = rootVc;

//4.设置主窗口显示

[self.window makeKeyAndVisible];



#pragma mark - 控制器的几种创建方式


1.alloc  init


2.Storyboard

> 箭头指向的board

//    UIStoryboard *board =[UIStoryboard storyboardWithName:@"ITC" bundle:nil];

//    UIViewController *targatVc = [board instantiateInitialViewController];


> 非箭头指向的board

//UIViewController *targatVc = [board instantiateViewControllerWithIdentifier:@"twoYellow"];


3.xib

>指定的xib

//ITCViewController *targatVc = [[ITCViewController alloc]initWithNibName:@"ITC" bundle:nil];


>同名的xib


>同名去掉controller




#pragma mark - 导航控制器的基本使用


//跳转(添加)下一个控制器

pushViewController:two animated:YES


//返回(销毁)上一个控制器

poptoViewController:two animated:YES


//返回到第一个子控制器

poptoRootViewControllerAnimated:YES






#pragma mark - 导航控制器的导航栏的设置


导航栏的内容由栈顶控制器的navigationItem属性决定

UINavigationItem有以下属性影响着导航栏的内容

//左上角的返回按钮

@property(nonatomic,retain) UIBarButtonItem *backBarButtonItem;


//中间的标题视图

@property(nonatomic,retain) UIView          *titleView;


//中间的标题文字

@property(nonatomic,copy)   NSString        *title;


//左上角的按钮

@property(nonatomic,retain) UIBarButtonItem *leftBarButtonItem;


//右上角的按钮

@property(nonatomic,retain) UIBarButtonItem *rightBarButtonItem;




#pragma mark - UIStoryboardSegue


//Segue 有关的两个方法:注意都是由当前的控制器使用

//手动型跳转:根据ID 判断是哪一根线

performSegueWithIdentifier:NSString *identifier sender:(id)sender


//根据segue 准备跳转的时刻

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender




#pragma mark - 控制器的生命周期


//控制器View加载完毕时

- (void)viewDidLoad;


//控制器VIew的即将显示

- (void)viewWillAppear:(BOOL)animated;

//控制器View已经显示

- (void)viewDidAppear:(BOOL)animated;



//控制器View即将消失

- (void)viewWillDisappear:(BOOL)animated;


//控制器View已经消失

- (void)viewDidDisappear:(BOOL)animated;

//内存警告 释放内存

- (void)didReceiveMemoryWarning





//过时的方法

//控制器View即将被销毁

- (void)viewWillUnload


//控制器的View 已经被销毁

- (void)viewDidUnload



#pragma mark - UI进阶03



//1.创建HUD

MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];

//2.设置提醒内容

hud.labelText = @"正在拼命登录。。。";

//3.副标题

hud.detailsLabelText = @"请稍后";

//注意点:如果想 调用 自定义图片 需要设置 自定义模式

//4.自定义图片

hud.mode = MBProgressHUDModeCustomView;

hud.customView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"MBProgressHUD.bundle/success"]];


//5.设置蒙版效果

hud.dimBackground = YES;


//6.展示

[hud show:YES];


//7.隐藏

[hud hide:YES];




//3.垃圾箱 按钮的功能实现


1.开启tableView 的编辑模式    self.tableView.editing = ! self.tableView.editing;

2.实现滑动删除

3.设置 中文 删除


//代理 实现滑动删除

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {

    if (editingStyle == UITableViewCellEditingStyleDelete) {

        

        //删除数据

        [self.contactArray removeObjectAtIndex:indexPath.row];

        

        //更新UI

        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];

        

        

    } else if (editingStyle == UITableViewCellEditingStyleInsert) {

        

        NSLog(@"添加 一条数据");

        

    }

}


//设置滑动删除按钮的 文字

- (NSString *)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath

{

    return @"删除";

}



//代理 刷新数据


//1.1获取 选中的 角标

NSIndexPath *idx = [self.tableView indexPathForSelectedRow];



//2.刷新表格

//2.1全局刷新

//    [self.tableView reloadData];


//2.2局部刷新

[self.tableView reloadRowsAtIndexPaths:@[idx] withRowAnimation:UITableViewRowAnimationRight];



#pragma mark - UI进阶04


document 路径

[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]




#pragma mark - 2数据的三种存储方式

//1.writeTofile

[names writeToFile:path atomically:YES];


//2.偏好设置 存储

1.获取偏好设置对象

NSUserDefaults *defaul = [NSUserDefaults standardUserDefaults];


2.存储数据

[defaul setObject:@"小明" forKey:@"name"];

[defaul setInteger:100 forKey:@"money"];

[defaul setBool:NO forKey:@"youmeiyou"];


3.立即同步

[defaul synchronize];


//3.归档

[NSKeyedArchiver archiveRootObject:p toFile:path];

解档

Person *p =  [NSKeyedUnarchiver  unarchiveObjectWithFile:path];


1.遵守 NSCoding 协议

//"归档"只是 存储数据的过程

//这是告诉系统 对象的哪些属性需要存储,该如何存储;若该属性没写不会存储进去

-(void)encodeWithCoder:(NSCoder *)aCoder

{

    [aCoder encodeObject:self.name forKey:@"name"];

    [aCoder encodeInt:self.girl forKey:@"girl"];

    [aCoder encodeBool:self.sure forKey:@"sure"];

    

}


//"归档"只是 读取数据的过程

//这是告诉系统 取出的哪些数据赋值给对象的哪些属性,若该属性没写不会获取出来

- (instancetype)initWithCoder:(NSCoder *)aDecoder

{

    

    if(self = [super init]){

        

        self.name =  [aDecoder  decodeObjectForKey:@"name"];

        self.girl = [aDecoder decodeIntForKey:@"girl"];

        self.sure = [aDecoder decodeBoolForKey:@"sure"];

        

    }

    

    return self;

}





#pragma mark - 4 UITabBarController基本使用


//1.创建 tabBar 控制器

UITabBarController *tab = [[UITabBarController alloc]init];

//2.设置颜色

tab.tabBar.tintColor = [UIColor greenColor];


//3、创建子控制器

redViewController *red = [[redViewController alloc]init];


//3.1设置tabBarItem title

red.tabBarItem.title = @"联系人";


//3.2设置tabBarItem 的图片

red.tabBarItem.image = [UIImage imageNamed:@"tabbar_contacts"];


//3.3设置tabBarItem 的选中图片,iOS7.0  之后有图片渲染效果 ,所以特殊设置

UIImage *imge = [UIImage imageNamed:@"tabbar_contactsHL"];

//    imge = [imge imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];


red.tabBarItem.selectedImage = imge;


//3.4右上角的角标

red.tabBarItem.badgeValue = @"10";



//4、给tab 添加子控制器

//逐个添加

//    [tab addChildViewController:red];

//    [tab addChildViewController:blue];

//一次性添加

tab.viewControllers = @[red,blue];





iOS7.0之后出现的图片渲染效果


UIImageRenderingModeAutomatic        根据图片的使用环境和所处的绘图上下文自动调整渲染模式。

UIImageRenderingModeAlwaysOriginal    始终绘制图片原始状态,不使用Tint Color

UIImageRenderingModeAlwaysTemplate   始终根据Tint Color绘制图片,忽略图片的颜色信息。




Modal的形式展示控制器

- (void)presentViewController:(UIViewController *)viewControllerToPresent animated: (BOOL)flag completion:(void (^)(void))completion

关闭当初Modal出来的控制器

- (void)dismissViewControllerAnimated: (BOOL)flag completion: (void (^)(void))completion;

原则:谁Modal,谁dismiss


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值