developer
2023-05-20 c1ffd99c4b60066774eb2c97b31e4aaa014e7f51
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
//
//  ConfirmTheGoodsViewController.m
//  BuWanVideo2.0
//
//  Created by apple on 17/1/6.
//  Copyright © 2017年 com.yeshi.buwansheque.ios. All rights reserved.
//
 
#import "ConfirmTheGoodsViewController.h"
 
@interface ConfirmTheGoodsViewController ()
 
@end
 
@implementation ConfirmTheGoodsViewController
 
- (void)viewDidLoad {
    [super viewDidLoad];
    //返回按钮
    UIButton *backButton=[UIButton buttonWithType:UIButtonTypeRoundedRect];
    backButton.frame=CGRectMake(0, 0, 50, 44);
    [backButton setTitle:@"<返回" forState:UIControlStateNormal];
    [backButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    backButton.titleLabel.font = [UIFont systemFontOfSize:17.0];
    [backButton addTarget:self action:@selector(BackClick:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *backBtnItem=[[UIBarButtonItem alloc] initWithCustomView:backButton];
    self.navigationItem.leftBarButtonItem=backBtnItem;
    
    //标题
    UILabel *TLabel=[[UILabel alloc] initWithFrame:CGRectMake(0, 0, 50, 44)];
    TLabel.text=@"发布";
    TLabel.textColor=[UIColor whiteColor];
    TLabel.font=[UIFont systemFontOfSize:18];
    self.navigationItem.titleView=TLabel;
    
    //增加通知中心监听,当键盘出现或消失时收出消息
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWasShown:) name:UIKeyboardWillShowNotification object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
    
    _imageH.constant=(KScreenW-16)/15*14;
}
 
-(void)BackClick:(UIButton *)sender{
    [self.navigationController popViewControllerAnimated:NO];
}
 
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [_textView resignFirstResponder];
}
 
#pragma mark 键盘隐藏
-(void)keyboardWillHide:(NSNotification *)notification{
    _imageH.constant=(KScreenW-16)/15*14;
    _KeyBoradH.constant=0;
}
 
#pragma mark 键盘出现
-(void)keyboardWasShown:(NSNotification *)notification{
    NSDictionary* info = [notification userInfo];
    CGSize kbSize = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].size;//得到键盘的高度
    
    _imageH.constant=(KScreenW-16)/15*14-kbSize.height;
    _KeyBoradH.constant=kbSize.height;
}
 
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
 
@end