【iOS】UI学习——导航控制器、分栏控制器

UI学习(三)

  • 导航控制器
    • 导航控制器基础
    • 导航控制器切换
    • 导航栏和工具栏
  • 分栏控制器
    • 分栏控制器基础
    • 分栏控制器高级

导航控制器

在这里插入图片描述
导航控制器负责控制导航栏(navigationBar),导航栏上的按钮叫UINavigationItem(导航元素项)。它还控制着一个视图控制器,即导航栏下面的东西。

导航控制器基础

#import "SceneDelegate.h"
#import "VCRoot.h"

@interface SceneDelegate ()

@end

@implementation SceneDelegate


- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions {
    //创建一个根视图控制器
    VCRoot* root = [[VCRoot alloc] init];
    //创建导航控制器
    //导航控制器主要用来管理多个视图控制器的切换
    //层级的方式来管理多个视图控制器
    //创建控制器时,一定要有一个根视图控制器
    //P1:就是作为导航控制器的根视图控制器
    UINavigationController* rev = [[UINavigationController alloc] initWithRootViewController:root];
    //将window的根视图设置为导航控制器
    self.window.rootViewController = rev;
    [self.window makeKeyAndVisible];
}

新建一个VCRoot类

#import "VCRoot.h"

@interface VCRoot ()

@end

@implementation VCRoot

- (void)viewDidLoad {
    [super viewDidLoad];
    //设置导航栏的透明度
    //默认透明度为YES:可透明的
    self.navigationController.navigationBar.translucent = NO;
    self.view.backgroundColor = [UIColor greenColor];
    //设置导航栏的标题文字
    self.title = @"娃哈哈";
    //设置导航元素项目的标题
    //如果没有设置元素项目的标题,系统会使用self.title作为标题;反之,优先为navigationItem.title
    self.navigationItem.title = @"娃哈哈1";
    //向左侧按钮中添加文字,这里是根据title文字来创建
    //P1:栏按钮项的标题
    //P2:按钮的样式
    //P3:接受动作的目标对象
    UIBarButtonItem* leftBtn = [[UIBarButtonItem alloc] initWithTitle:@"旺仔牛奶" style:UIBarButtonItemStyleDone target:self action:@selector(pressLeft)];
    
    self.navigationItem.leftBarButtonItem = leftBtn;
    //右侧按钮中的文字是不可变的
    //这里按钮是制定了系统提供的风格样式
    //P1:按钮中展现的东西,注意,这里无论按钮中展现的是什么内容(无论图案或者文字),都是不可改变的
    UIBarButtonItem* rightBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(pressRight)];
    //向右侧添加自定义按钮
    UILabel* label = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 50, 40)];
    label.text = @"矿泉水";
    //将文字调至中间位置
    label.textAlignment = NSTextAlignmentCenter;
    label.textColor = [UIColor blackColor];
    //UIView的子类都可以被添加
    UIBarButtonItem* item = [[UIBarButtonItem alloc] initWithCustomView:label];
    //数组展现顺序从右至左
    NSArray* array = [NSArray arrayWithObjects:item, rightBtn, nil];
    //将右侧按钮数组赋值
    self.navigationItem.rightBarButtonItems = array;
    //self.navigationItem.rightBarButtonItem = rightBtn;
}

-(void) pressLeft
{
    NSLog(@"按下了左侧按钮");
}

-(void) pressRight
{
    NSLog(@"按下了右侧按钮");
}

效果图
在这里插入图片描述

导航控制器切换

navigationBar:导航栏对象
navigationItem:导航元素项对象
translucent:导航栏透明度
pushViewController:推入视图控制器
popViewController:推出视图控制器

首先创建三个视图
根视图VCRoot.m

#import "VCRoot.h"
#import "VCTwo.h"
@interface VCRoot ()

@end

@implementation VCRoot

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor greenColor];
    //设置导航栏的透明度,默认为YES:可透明的;NO:不可透明的
    self.navigationController.navigationBar.translucent = NO;
    self.title = @"哦哦哦";
    //设置导航栏的风格颜色,默认为Default
    self.navigationController.navigationBar.barStyle = UIBarStyleDefault;
    //为根视图的导航控制器设置右侧按钮
    UIBarButtonItem* rightBtn = [[UIBarButtonItem alloc] initWithTitle:@"下一页" style:UIBarButtonItemStylePlain target:self action:@selector(pressRight)];
    self.navigationItem.rightBarButtonItem = rightBtn;
}

-(void) pressRight
{
    //创建新的视图控制器
    VCTwo* vcTwo = [[VCTwo alloc] init];
    //使用当前视图控制器的导航控制器对象
    [self.navigationController pushViewController:vcTwo animated:YES];
}

第二个视图VCTwo.h

#import "VCTwo.h"
#import "VCRoot.h"
#import "VCThree.h"
@interface VCTwo ()

@end

@implementation VCTwo
@synthesize elertView = _elertView;
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    //设置视图二的标题和颜色
    self.view.backgroundColor = [UIColor blueColor];
    UIBarButtonItem* leftBtn = [[UIBarButtonItem alloc] initWithTitle:@"上一页" style:UIBarButtonItemStylePlain target:self action:@selector(pressLeft)];
    UIBarButtonItem* rightBtn = [[UIBarButtonItem alloc] initWithTitle:@"下一页" style:UIBarButtonItemStylePlain target:self action:@selector(pressRight)];
    self.navigationItem.leftBarButtonItem = leftBtn;
    //[self create];
    self.navigationItem.rightBarButtonItem = rightBtn;
}

-(void) pressLeft
{
     //弹出当前视图控制器,返回上一个界面
    [self.navigationController popViewControllerAnimated:YES];
}

-(void) pressRight
{
    VCThree* vcThree = [[VCThree alloc] init];
    //推入第三个视图控制器对象
    [self.navigationController pushViewController:vcThree animated:YES];
}

第三个视图VCThree.h

#import "VCThree.h"
#import "VCRoot.h"
#import "VCTwo.h"
@interface VCThree ()

@end

@implementation VCThree

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor redColor];
    UIBarButtonItem* leftBtn = [[UIBarButtonItem alloc] initWithTitle:@"上一页" style:UIBarButtonItemStylePlain target:self action:@selector(pressLeft)];
    UIBarButtonItem* rightBtn = [[UIBarButtonItem alloc] initWithTitle:@"下一页" style:UIBarButtonItemStylePlain target:self action:@selector(pressRight)];
    self.navigationItem.leftBarButtonItem = leftBtn;
    self.navigationItem.rightBarButtonItem = rightBtn;
}

-(void) pressLeft
{
    [self.navigationController popViewControllerAnimated:YES];
}

-(void) pressRight
{
    //弹出当前视图,返回根视图
    [self.navigationController popToRootViewControllerAnimated:YES];
}

效果图
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

导航栏和工具栏

ScenDelegate.m

#import "SceneDelegate.h"
#import "VCRoot.h"
@interface SceneDelegate ()

@end

@implementation SceneDelegate


- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions {
    VCRoot* vac = [[VCRoot alloc] init];
    UINavigationController* ans = [[UINavigationController alloc] initWithRootViewController:vac];
    self.window.rootViewController = ans;
    [self.window makeKeyAndVisible];
}


- (void)sceneDidDisconnect:(UIScene *)scene {
    // Called as the scene is being released by the system.
    // This occurs shortly after the scene enters the background, or when its session is discarded.
    // Release any resources associated with this scene that can be re-created the next time the scene connects.
    // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead).
}


- (void)sceneDidBecomeActive:(UIScene *)scene {
    // Called when the scene has moved from an inactive state to an active state.
    // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.
}


- (void)sceneWillResignActive:(UIScene *)scene {
    // Called when the scene will move from an active state to an inactive state.
    // This may occur due to temporary interruptions (ex. an incoming phone call).
}


- (void)sceneWillEnterForeground:(UIScene *)scene {
    // Called as the scene transitions from the background to the foreground.
    // Use this method to undo the changes made on entering the background.
}


- (void)sceneDidEnterBackground:(UIScene *)scene {
    // Called as the scene transitions from the foreground to the background.
    // Use this method to save data, release shared resources, and store enough scene-specific state information
    // to restore the scene back to its current state.
}


@end

VCRoot.h

#import "VCRoot.h"
#import "VCSecond.h"
@interface VCRoot ()

@end

@implementation VCRoot

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor yellowColor];
    
    self.title = @"根视图";
    
    UIBarButtonItem* btn = [[UIBarButtonItem alloc] initWithTitle:@"Right" style:UIBarButtonItemStylePlain target:nil action:nil];
    
    self.navigationItem.rightBarButtonItem = btn;
    UINavigationBarAppearance* appearance = [[UINavigationBarAppearance alloc] init];
    //设置该对象的背景颜色
    appearance.backgroundColor = [UIColor redColor];
    //创建该对象的阴影图像
    appearance.shadowImage = [[UIImage alloc] init];
    //设置该对象的阴影颜色
    appearance.shadowColor = nil;
    //设置导航栏按钮的颜色
    self.navigationController.navigationBar.tintColor = [UIColor blueColor];
    //设置普通样式导航栏
    self.navigationController.navigationBar.standardAppearance = appearance;
    //设置滚动样式导航栏
    self.navigationController.navigationBar.scrollEdgeAppearance = appearance;
    
    self.navigationController.navigationBar.hidden = NO;
    
    self.navigationController.navigationBarHidden = NO;
    //显示工具栏对象
    //默认工具栏是隐藏的
    self.navigationController.toolbarHidden = NO;
    //设置工具栏是否透明
    self.navigationController.toolbar.translucent = NO;
    //向工具栏添加第一个按钮
    UIBarButtonItem* btn1 = [[UIBarButtonItem alloc] initWithTitle:@"left" style:UIBarButtonItemStylePlain target:nil action:nil];
    //向工具栏添加第二个按钮
    UIBarButtonItem* btn2 = [[UIBarButtonItem alloc] initWithTitle:@"right" style:UIBarButtonItemStylePlain target:nil action:@selector(press)];
    //添加一个自定义按钮
    UIButton *btnC = [UIButton buttonWithType: UIButtonTypeCustom];
    [btnC setImage: [UIImage imageNamed: @"12.png"] forState: UIControlStateNormal];
    btnC.frame = CGRectMake(0, 0, 60, 60);
        
    UIBarButtonItem *btn3 = [[UIBarButtonItem alloc] initWithCustomView: btnC];
        
    //设置一个占位按钮,放到数组中可以用来分隔开各按钮
    //设置宽度固定按钮
    UIBarButtonItem *btnF1 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem: UIBarButtonSystemItemFixedSpace target: nil action: nil];
    btnF1.width = 110;
        
    //设置自动计算宽度按钮
    UIBarButtonItem *btnF2 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem: UIBarButtonSystemItemFlexibleSpace target: nil action: nil];
    //按钮数组的创建
    NSArray *arrayBtn = [NSArray arrayWithObjects: btn1, btnF2, btn3, btnF2, btn2, nil];
        
    self.toolbarItems = arrayBtn;

    
}

效果图
在这里插入图片描述

分栏控制器

分栏控制器是管理多个视图控制器的管理控制器,通过数组的方式管理多个平行关系的视图控制器,与导航控制器的区别在于:导航控制器管理的是有层级关系的控制器

注意:
分栏控制器在同一界面最多显示5个控制器切换按钮,超过5个时会自动创建一个新的导航控制器来管理其余的控制器。

分栏控制器基础

UITabBarItem:分栏按钮元素对象
badgeValue:分栏按钮提示信息
selectedIndex:分栏控制器选中的控制器索引
viewControllers:分栏控制器管理数组
selectedViewController:分栏控制器选中的控制器对象

VCone类

#import "VCone.h"

@interface VCone ()

@end

@implementation VCone

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    //创建一个分栏按钮对象
    //P1:显示的文字
    //P2:显示图片图标
    //P3:设置按钮的tag
    UITabBarItem* tab = [[UITabBarItem alloc] initWithTitle:@"111" image:nil tag:101];
    
    self.tabBarItem = tab;
}
@end

VCtow类

#import "VCtwo.h"

@interface VCtwo ()

@end

@implementation VCtwo

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    //根据系统风格创建分栏按钮
    //P1:系统风格设定
    UITabBarItem* tab = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemContacts tag:111];
    tab.badgeValue = @"11";
    
    self.tabBarItem = tab;
}
@end

VCthree类

#import "VCthree.h"

@interface VCthree ()

@end

@implementation VCthree

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

/*
#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

SceneDelegate.m

#import "SceneDelegate.h"
#import "VCone.h"
#import "VCtwo.h"
#import "VCthree.h"

@interface SceneDelegate ()

@end

@implementation SceneDelegate


- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions {
    //创建视图控制器1、2、3
    VCone* vc1 = [[VCone alloc] init];
    
    vc1.title = @"视图一";
    vc1.view.backgroundColor = [UIColor whiteColor];
    
    VCtwo* vc2 = [[VCtwo alloc] init];
    vc2.title = @"视图二";
    vc2.view.backgroundColor = [UIColor redColor];
    
    VCthree* vc3 = [[VCthree alloc] init];
    vc3.view.backgroundColor = [UIColor orangeColor];
    vc3.title = @"视图三";
    //创建分栏控制器对象
    UITabBarController* tbController = [[UITabBarController alloc] init];
    
    //创建一个控制器数组对象
    //将所有要被分栏控制器管理的对象添加到数组中去
    NSArray* arrVC = [NSArray arrayWithObjects:vc1, vc2, vc3, nil];
    //给分栏控制器管理数组赋值
    tbController.viewControllers = arrVC;
    //将分栏控制器作为根视图控制器
    self.window.rootViewController = tbController;
    //设置选中的视图控制器的索引
    tbController.selectedIndex = 2;
    //当前显示的控制器对象
    if(tbController.selectedViewController == vc3) {
        NSLog(@"Right");
    }
    //是否分栏控制器的工具栏的透明度
    tbController.tabBar.translucent = NO;
    //分栏控制器的颜色
    tbController.tabBar.backgroundColor = [UIColor whiteColor];
    
    
    
    
}


- (void)sceneDidDisconnect:(UIScene *)scene {
    // Called as the scene is being released by the system.
    // This occurs shortly after the scene enters the background, or when its session is discarded.
    // Release any resources associated with this scene that can be re-created the next time the scene connects.
    // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead).
}


- (void)sceneDidBecomeActive:(UIScene *)scene {
    // Called when the scene has moved from an inactive state to an active state.
    // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.
}


- (void)sceneWillResignActive:(UIScene *)scene {
    // Called when the scene will move from an active state to an inactive state.
    // This may occur due to temporary interruptions (ex. an incoming phone call).
}


- (void)sceneWillEnterForeground:(UIScene *)scene {
    // Called as the scene transitions from the background to the foreground.
    // Use this method to undo the changes made on entering the background.
}


- (void)sceneDidEnterBackground:(UIScene *)scene {
    // Called as the scene transitions from the foreground to the background.
    // Use this method to save data, release shared resources, and store enough scene-specific state information
    // to restore the scene back to its current state.
}


@end

效果图在这里插入图片描述

分栏控制器高级

willBeginCustomizingViewControllers:即将显示编辑方法
willEndCustomizingViewControllers:即将结束编辑方法
didEndCustomizingViewControllers:已经结束编辑方法
didSelectViewController:选中控制器切换方法

分栏控制器下面的导航栏最多显示5个按钮,超过5个按钮,系统会自动将最后一个按钮替换成more,当点击more时,才可以看到其他的按钮,点开后,右上角有一个Edit按钮,点击可以看到所有的按钮,也可拖动改变前四个按钮展现的是什么视图。

UITabBarControllerDelegate协议
先创建VCone-Vcsix类,这里指展现VCone类:

#import "VCone.h"

@interface VCone ()

@end

@implementation VCone

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

/*
#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

SceneDelegate.m

#import "SceneDelegate.h"
#import "VCone.h"
#import "VCtwo.h"
#import "VCthree.h"
#import "VCfour.h"
#import "VCfive.h"
#import "VCsix.h"
@interface SceneDelegate ()

@end

@implementation SceneDelegate


- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions {
    VCone* vc1 = [[VCone alloc] init];
    vc1.title = @"视图1";
    vc1.view.backgroundColor = [UIColor redColor];
    
    VCtwo* vc2 = [[VCtwo alloc] init];
    vc2.title = @"视图2";
    vc2.view.backgroundColor = [UIColor orangeColor];
    
    VCthree* vc3 = [[VCthree alloc] init];
    vc3.title = @"视图3";
    vc3.view.backgroundColor = [UIColor blueColor];
    
    VCfour* vc4 = [[VCfour alloc] init];
    vc4.title = @"视图4";
    vc4.view.backgroundColor = [UIColor greenColor];
    
    VCfive* vc5 = [[VCfive alloc] init];
    vc5.title = @"视图5";
    vc5.view.backgroundColor = [UIColor grayColor];
    
    VCsix* vc6 = [[VCsix alloc] init];
    vc6.title = @"视图6";
    vc6.view.backgroundColor = [UIColor yellowColor];
    
    
    NSArray* arrVC = [NSArray arrayWithObjects:vc1, vc2, vc3, vc4, vc5, vc6, nil];
    UITabBarController* tb = [[UITabBarController alloc] init];
    tb.viewControllers = arrVC;
    tb.tabBar.translucent = NO;
    tb.tabBar.backgroundColor = [UIColor whiteColor];
    self.window.rootViewController = tb;
    //设置代理
    //处理UITabBarControllerDelegate协议函数
    tb.delegate = self;
}
//开始编译前调用此协议函数
-(void) tabBarController:(UITabBarController *)tabBarController willBeginCustomizingViewControllers:(NSArray<__kindof UIViewController *> *)viewControllers
{
    NSLog(@"编辑前");
}
//即将结束编译前调用此协议函数
-(void) tabBarController:(UITabBarController *)tabBarController willEndCustomizingViewControllers:(NSArray<__kindof UIViewController *> *)viewControllers changed:(BOOL)changed
{
    NSLog(@"即将结束前");
}
//结束编译后调用此协议函数
-(void) tabBarController:(UITabBarController *)tabBarController didEndCustomizingViewControllers:(NSArray<__kindof UIViewController *> *)viewControllers changed:(BOOL)changed
{
    if(changed == YES) {
        NSLog(@"顺序发生改变");
    }
    NSLog(@"已经结束编辑");
}
//选中控制器对象调用此协议函数
-(void) tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
    NSLog(@"选中控制器对象");
}


- (void)sceneDidDisconnect:(UIScene *)scene {
    // Called as the scene is being released by the system.
    // This occurs shortly after the scene enters the background, or when its session is discarded.
    // Release any resources associated with this scene that can be re-created the next time the scene connects.
    // The scene may re-connect later, as its session was not necessarily discarded (see `application:didDiscardSceneSessions` instead).
}


- (void)sceneDidBecomeActive:(UIScene *)scene {
    // Called when the scene has moved from an inactive state to an active state.
    // Use this method to restart any tasks that were paused (or not yet started) when the scene was inactive.
}


- (void)sceneWillResignActive:(UIScene *)scene {
    // Called when the scene will move from an active state to an inactive state.
    // This may occur due to temporary interruptions (ex. an incoming phone call).
}


- (void)sceneWillEnterForeground:(UIScene *)scene {
    // Called as the scene transitions from the background to the foreground.
    // Use this method to undo the changes made on entering the background.
}


- (void)sceneDidEnterBackground:(UIScene *)scene {
    // Called as the scene transitions from the foreground to the background.
    // Use this method to save data, release shared resources, and store enough scene-specific state information
    // to restore the scene back to its current state.
}


@end

效果图
在这里插入图片描述
点击more后
在这里插入图片描述
点击Edit后
在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/676000.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

数据挖掘API拼多多API接口通过id抓取商品详情页数据已拼人数等:打造无缝电商体验的秘诀

引言&#xff1a; 在当今的电商领域&#xff0c;提供无缝、高效的购物体验是吸引和保留客户的关键。拼多多API接口正是这样一个工具&#xff0c;它可以帮助商家实现这一目标。接下来&#xff0c;我们将深入了解拼多多API如何助力商家打造卓越的电商体验。 一、拼多多API的重要…

[线程与网络] 网络编程与通信原理(五): 深入理解网络层IP协议与数据链路层以太网协议

&#x1f338;个人主页:https://blog.csdn.net/2301_80050796?spm1000.2115.3001.5343 &#x1f3f5;️热门专栏:&#x1f355; Collection与数据结构 (92平均质量分)https://blog.csdn.net/2301_80050796/category_12621348.html?spm1001.2014.3001.5482 &#x1f9c0;Java …

#招聘数据分析#2024年5月前程无忧招聘北上广深成渝对比情况

#招聘数据分析#2024年5月前程无忧招聘北上广深成渝对比情况 0、根据前程无忧不完全样本统计&#xff0c;北上广深成都重庆平均月工资从高到低依次为 北京15037元、上海14230元、深圳13230元、广州11125元、成都10614元、重庆10388。 1、成都招聘样本数全量36301个&#xff0c…

在家AIAA(美国航空航天学会)文献如何查找下载

今天有位同学的求助文献来自AIAA&#xff08;美国航空航天学会&#xff09;&#xff0c;下面就讲一下不用求助他人自己就可搞定文献下载的途径并实例操作演示。 首先我们先对AIAA&#xff08;美国航空航天学会&#xff09;数据库做个简单的了解&#xff1a; 美国航空航天学会…

C语言:(动态内存管理)

目录 动态内存有什么用呢 malloc函数 开辟失败示范 free函数 calloc函数 realloc函数 当然realooc也可以开辟空间 常⻅的动态内存的错误 对NULL指针的解引⽤操作 对动态内存开辟的空间越界访问 对⾮动态开辟内存使⽤free释放 使⽤free释放⼀块动态开辟内存的⼀部分 …

网络安全宣传 | 干货满满,这些网络安全知识请牢记!

随着社会信息化深入发展 互联网对人类文明进步将发挥更大促进作用 但与此同时&#xff0c;互联网领域的问题也日益凸显 网络犯罪、网络监听、网络攻击等时有发生 网络安全与每个人都息息相关 下面 一起来了解网络安全知识吧 网络安全是什么&#xff1f; 网络安全&#x…

2、Tomcat 线程模型详解

2、Tomcat 线程模型详解 Tomcat I/O模型详解Linux I/O模型详解I/O要解决什么问题Linux的I/O模型分类 Tomcat支持的 I/O 模型Tomcat I/O 模型如何选型 网络编程模型Reactor线程模型单 Reactor 单线程单 Reactor 多线程主从 Reactor 多线程 Tomcat NIO实现Tomcat 异步IO实现 Tomc…

重学java 56. Map集合

我们要拥有一定成功的信念 —— 24.6.3 一、双列集合的集合框架 HashMap 1.特点: a.key唯一,value可重复 b.无序 c.无索引 d.线程不安全 e.可以存null键,null值 2.数据结构:哈希表 LinkedHashMap&#xff08;继承HashMap&#xff09; 1.特点: a.key唯一,value可重复 b.有序 c.无…

特征工程技巧—Bert

前段时间在参加比赛&#xff0c;发现有一些比赛上公开的代码&#xff0c;其中的数据预处理步骤值得我们参考。 平常我们见到的都是数据预处理&#xff0c;现在我们来讲一下特征工程跟数据预处理的区别。 数据预处理是指对原始数据进行清洗、转换、缩放等操作&#xff0c;以便为…

Redis中大Key与热Key的解决方案

原文地址&#xff1a;https://mp.weixin.qq.com/s/13p2VCmqC4oc85h37YoBcg 在工作中Redis已经成为必备的一款高性能的缓存数据库&#xff0c;但是在实际的使用过程中&#xff0c;我们常常会遇到两个常见的问题&#xff0c;也就是文章标题所说的大 key与热 key。 一、定义 1.1…

Vulnhub项目:THE PLANETS: MERCURY

1、靶场地址 The Planets: Mercury ~ VulnHubThe Planets: Mercury, made by SirFlash. Download & walkthrough links are available.https://vulnhub.com/entry/the-planets-mercury,544/ 这好像是个系列的&#xff0c;关于星球系列&#xff0c;之前还做过一个地球的&a…

毕业论文word常见问题

0、前言&#xff1a; 这里的问题都是以office办公软件当中的word为例&#xff0c;和WPS没有关系。 1、页眉横线删不掉&#xff1a; 解决方案&#xff1a;进入页眉编辑状态&#xff0c;在开始选项栏中选择页眉字体样式&#xff0c;清除格式。 修改方式如下&#xff1a; 2、…

从网路冲浪到three.js+cannon.js

从网路冲浪开始 网络浏览器的发展史可以追溯到互联网的早期,随着时间的推移,浏览器已经经历了多次重大的变革和发展。 以下是网络浏览器发展史的一个简要概述: 1. 早期的文本浏览器 1990年:蒂姆伯纳斯-李(Tim Berners-Lee)开发了第一个网络浏览器WorldWideWeb(后来更名…

【十二】图解mybatis日志模块之设计模式

图解mybatis日志模块之设计模式 概述 最近经常在思考研发工程师初、中、高级工程师以及系统架构师各个级别的工程师有什么区别&#xff0c;随着年龄增加我们的技术级别也在提升&#xff0c;但是很多人到了高级别反而更加忧虑&#xff0c;因为it行业35岁年龄是个坎这是行业里的共…

【轻松搞定形象照】助你打造编程等级考试、竞赛专属二寸靓照,报名无忧,展现最佳风采!

更多资源请关注纽扣编程微信公众号 ​ 在数字化时代&#xff0c;拍照似乎变得轻而易举&#xff0c;但当我们需要一张特定规格的一寸照片时&#xff0c;事情就变得复杂起来。随着编程等级考试和各类信息学竞赛的日益临近&#xff0c;不少考生都为了一张符合要求的一寸照片而忙…

2.2 OpenCV随手简记(三)

图像的阈值处理定义 &#xff1a;将图像转化为二值图像&#xff08;黑白图&#xff09;, 也可以用于彩色图形&#xff0c;达到夸张的效果 目的&#xff1a;是用来提取图像中的目标物体&#xff0c;将背景和噪声区分开&#xff08;可以近似的认为除了目标全是噪声&#xff09;。…

Capto 标准版【简体中文+Mac 】

Capto 是一套易于使用的屏幕捕捉、视频录制和视频编辑 Capto-capto安装包-安装包https://souurl.cn/DPhBmP 屏幕录制和教程视频制作 记录整个屏幕或选择的任何特定区域。在创建内容丰富的教程视频时选择显示或隐藏光标。无论您做什么&#xff0c;都可以确保获得高质量的视频。…

C# WinForm —— 24 Threading.Timer 组件介绍与使用

1. 简介 System.Threading.Timer 多线程 轻量级 精度高 提供以指定的时间间隔对线程池线程执行方法的机制 和System.Timers.Timer 类似&#xff0c;每隔一段时间触发事件&#xff0c;执行操作(不是由UI线程执行的)&#xff0c;即使事件中执行了比较耗时的操作&#xff0c;也…

教育新基建背景下的光网校园:安徽中澳科技职业学院以太全光网建设之路

作者/安徽中澳科技职业学院 网络中心 刘正峰 安徽中澳科技职业学院隶属于安徽省科技厅,是一所公办高等职业院校。学院在“德厚三分,技高一筹”的校训指引下,坚持“开放性、精品化、技能型”的发展理念,坚持“贴近市场需求、强化实践教学、突出办学特色、培养实用人才”的办学思…

一款高效办公软件及48个快捷键

君子生非异也&#xff0c;善假于物也。 一天&#xff0c;技术同事亲自操刀要撰写一篇公号文档&#xff0c;于是问我需要什么样的排版格式&#xff1f; 我很快甩了一篇《水经注文档排版规范》给对方。 片刻之后&#xff0c;同事觉得这样写文档的效率太低&#xff0c;于是说要…