首页 文章 精选 留言 我的

精选列表

搜索[ios],共10000篇文章
优秀的个人博客,低调大师

TFTP服务器在Cisco设备上的应用(上传、下载IOS)

网络拓扑图 基于对安全的考虑,Cisco总是默认关闭TELNET服务,并且只有配置了远程登陆密码才能使用。同时还要配置使能密码,负责不能进入特权模式。 实验一:通过TFTP服务器从Cisco路由器上下在系统 下面是远程登陆通信服务器主要承载路由器的管理 下面是具体的配置 Router(config)# enablepassword123 配置使能密码 Router(config)#l inevty04 进入线路配置模式 Router(config-line)# password123 加密 Router(config-line)# login 登陆时生效 Router(config-line)# end *Mar100:03:16.703:%SYS-5-CONFIG_I:Configuredfromconsolebyconsol %Noconnectionsopen Router# Router# write 保存到Startup-config中。 Buildingconfiguration... [OK] Router# Router(config)# interF0/0 Router(config-if)# ipadd172.16.2.209255.255.255.0 Router(config-if)# noshut Router(config-if)# *Mar100:05:02.095:%LINK-3-UPDOWN:InterfaceEthernet0/0,changedstatetoup *Mar100:05:03.095:%LINEPROTO-5-UPDOWN:LineprotocolonInterfaceEthernet0/ 0,changedstatetoup 开启TFTP服务器,写入LOG和输入、输出目录。 将路由器的F0/0直接连到局域网交换机某一接口上。 下面是远程登陆路由器F0/0接口上。主要承载路由器数据的传输。 登陆后的结果: 下面是在登陆172.16.0.209之后的具体配置: R5# copyflashtftp 将路由器上flash中的文件复制到tftp服务器上。 Sourcefilename[c2600-ik8o3s-mz.122-11.T.bin]? c2600-ik8o3s-mz.122-11.T.bin 输入需要复制的系统名 Addressornameofremotehost[]?1 72.16.0.5 TFTP服务器对应的主机的具体地址 Destinationfilename[c2600-ik8o3s-mz.122-11.T.bin]? 回车确认 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 15108540bytescopiedin174.982secs(86343bytes/sec) 复制已经完成 下面是显示结果: 下面是TFTP上复制过程的显示结果。 下面是下载下来的系统,其中config.text是一会做上传用的。 实验二:通过TFTP服务器给Cisco路由器上传配置文件 R5# copytftpflash 复制TFTP服务器输出目录里的confit.text文件到路由器的flash中。 Addressornameofremotehost[]? 172.16.0.5 TFTP服务器对应的主机地址。 Sourcefilename[]? config.text Destinationfilename[config.text]? Accessingtftp://172.16.0.5/config.text... Eraseflash:beforecopying? [confirm] j 任意输入一个字母(注意:不可直接按回车,否则,Flash里的所有文件,包括系统也被擦除了。 Loadingconfig.textfrom172.16.0.5(viaFastEthernet0/0):! [OK-20bytes] Verifyingchecksum...OK(0xE9E9) 20bytescopiedin0.221secs(90bytes/sec) R5# showflash Systemflashdirectory: FileLengthName/status 115108540c2600-ik8o3s-mz.122-11.T.bin 220config.text 可以看出文件已经复制到FLASH中了 [15108688bytesused,18445744available,33554432total] 32768KbytesofprocessorboardSystemflash(Read/Write) 可以看出上传成功了 下面是具体的配置命令! 本文转自凌激冰51CTO博客,原文链接:http://blog.51cto.com/dreamfire/99115,如需转载请自行联系原作者

优秀的个人博客,低调大师

iOS: 格式化新浪微博/QQ说说等等的发布时间

介绍:对于一些社交工具,我们可以发布一些说说或者心情什么的,如新浪微博,QQ,微信等,发布成功后,上面都会有一个发布的时间。 这个时间并不是具体的NSDate类型,而是经过格式化过的符合一般标准的模式,例如:发布于前一个月、前一个星期、前一天、十几分钟前、刚刚等。 下面就给出两个具体的测试Demo 头文件: // ViewController.m // 测试发布时间格式化 // // Created by mac on 16/1/26. // Copyright © 2016年 mac. All rights reserved. // #import "ViewController.h" #define knewsTimeFormat @"yyyyMMddHHmmss" //你要传过来日期的格式 #define kcreatedDateFormat @"EEE MMM dd HH:mm:ss Z yyyy" //你要传过来日期的格式 #define kLocaleIdentifier @"en_US" //时区类型 @interface ViewController () @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; 注意:传入的需要格式化的时间字符串必须与你设置的日期的格式对应 //测试一 NSString *str = @"20160126132609"; // 2016/01/26 13:26:09 NSLog(@"%@",[self newsTime:str]); //测试二 NSString *str2 = @"Tue Jan 26 13:50:08 +0800 2016"; NSLog(@"%@",[self formatCreatedDate:str2]); } 测试一: //方式一: 获取发布时间 - (NSString *)newsTime:(NSString *)newsTimes { NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; formatter.dateFormat = knewsTimeFormat; formatter.locale = [[NSLocale alloc] initWithLocaleIdentifier:kLocaleIdentifier]; NSDate *date = [formatter dateFromString:newsTimes]; NSDate *now = [NSDate date]; // 比较帖子发布时间和当前时间 NSTimeInterval interval = [now timeIntervalSinceDate:date]; NSString *format; if (interval <= 60) { format = @"刚刚"; } else if(interval <= 60*60){ format = [NSString stringWithFormat:@"发布于前%.f分钟", interval/60]; } else if(interval <= 60*60*24){ format = [NSString stringWithFormat:@"发布于前%.f小时", interval/3600]; } else if (interval <= 60*60*24*7){ format = [NSString stringWithFormat:@"发布于前%d天", (int)interval/(60*60*24)]; } else if (interval > 60*60*24*7 & interval <= 60*60*24*30 ){ format = [NSString stringWithFormat:@"发布于前%d周", (int)interval/(60*60*24*7)]; }else if(interval > 60*60*24*30 ){ format = [NSString stringWithFormat:@"发布于前%d月", (int)interval/(60*60*24*30)]; } formatter.dateFormat = format; return [formatter stringFromDate:date]; } 输出结果: 2016-01-26 14:32:28.324 测试发布时间格式化[1809:109947] 发布于前1小时 测试二: //方式二: 获取发布时间 -(NSString *)formatCreatedDate:(NSString *)newsTimes { NSDateFormatter *formatter = [[NSDateFormatter alloc]init]; formatter.dateFormat = kcreatedDateFormat; formatter.locale = [[NSLocale alloc]initWithLocaleIdentifier:kLocaleIdentifier]; NSDate *date = [formatter dateFromString:newsTimes]; NSDate *now = [NSDate date]; // 比较帖子发布时间和当前时间 NSTimeInterval timeInterval = [now timeIntervalSinceDate:date]; if(timeInterval < 60) //1分钟 { return @"最近"; } else if(timeInterval < 60*60) //1小时 { return [NSString stringWithFormat:@"%d分钟前",(int)timeInterval/60]; } else if(timeInterval < 60*60*24) //1天 { return [NSString stringWithFormat:@"%d小时前",(int)timeInterval/60/60]; } return [NSString stringWithFormat:@"%.1lf",timeInterval]; } @end 输出结果: 2016-01-26 14:32:28.325 测试发布时间格式化[1809:109947] 42分钟前 程序猿神奇的手,每时每刻,这双手都在改变着世界的交互方式! 本文转自当天真遇到现实博客园博客,原文链接:http://www.cnblogs.com/XYQ-208910/p/5160381.html ,如需转载请自行联系原作者

优秀的个人博客,低调大师

iOS:CYLTabBarController的具体使用实例:实现新浪微博的主流框架

使用CocoaPods或者手动集成将CYLTabBarController这个第三方框架导入项目后,截图如下: 在AppDelegate.m类中实现的代码如下: // AppDelegate.m // CYLTabBarController // // Created by mac on 16/1/28. // Copyright © 2016年 mac. All rights reserved. // #import "AppDelegate.h" #import <CYLTabBarController.h> #import <CYLTabBar.h> #import "HomeViewController.h" #import "MessageViewController.h" #import "ComposeViewController.h" #import "DiscoverViewController.h" #import "MineViewController.h" @interface AppDelegate () @end @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { //创建CYLTabBarController的对象 CYLTabBarController *CYLtabVC = [[CYLTabBarController alloc]init]; //设置CYLTabBarController对象的标签栏属性按钮 CYLtabVC.tabBarItemsAttributes = [self createTabBarItemsAttributes]; //设置CYLTabBarController对象的标签栏子控制器数组 CYLtabVC.viewControllers = [self createTabBarViewControllers]; //设置tabbar按钮的文字颜色 [self customizeInterface]; //设置添加按钮的事件,模态出发布控制器 if (CYLExternPushlishButton) { [CYLExternPushlishButton addTarget:self action:@selector(composeButtonClcked:) forControlEvents:UIControlEventTouchUpInside]; } //设置CYLTabBarController的对象的根控制器 [self.window setRootViewController:CYLtabVC]; return YES; } #pragma mark - 模态出发布控制器 -(void)composeButtonClcked:(id)sender{ ComposeViewController *composeVC = [[ComposeViewController alloc]init]; [self.window.rootViewController presentViewController:composeVC animated:YES completion:nil]; } #pragma mark - 创建标签栏子控制器数组 -(NSArray *)createTabBarViewControllers{ //主页 HomeViewController *homeVC = [[HomeViewController alloc] init]; UINavigationController *homeNaV = [[UINavigationController alloc]initWithRootViewController:homeVC]; //消息 MessageViewController *messageVC = [[MessageViewController alloc] init]; UINavigationController *messageNaV = [[UINavigationController alloc]initWithRootViewController:messageVC]; //发现 DiscoverViewController *foundVC = [[DiscoverViewController alloc]init]; UINavigationController *foundNaV = [[UINavigationController alloc]initWithRootViewController:foundVC]; //我的 MineViewController *mineVC = [[MineViewController alloc]init]; UINavigationController *mineNaV = [[UINavigationController alloc]initWithRootViewController:mineVC]; return @[homeNaV,messageNaV,foundNaV,mineNaV]; } #pragma mark - 创建标签栏按钮item数组 -(NSArray *)createTabBarItemsAttributes{ NSDictionary *dict1 = @{ CYLTabBarItemTitle : @"首页", CYLTabBarItemImage : @"tabbar_home", CYLTabBarItemSelectedImage : @"tabbar_home_selected", }; NSDictionary *dict2 = @{ CYLTabBarItemTitle : @"消息", CYLTabBarItemImage : @"tabbar_message_center", CYLTabBarItemSelectedImage : @"tabbar_message_center_selected", }; NSDictionary *dict3 = @{ CYLTabBarItemTitle : @"发现", CYLTabBarItemImage : @"tabbar_discover", CYLTabBarItemSelectedImage : @"tabbar_discover_selected", }; NSDictionary *dict4 = @{ CYLTabBarItemTitle : @"我的", CYLTabBarItemImage : @"tabbar_profile", CYLTabBarItemSelectedImage : @"tabbar_profile_selected", }; return @[ dict1, dict2, dict3, dict4]; } #pragma mark - 设置tabbar按钮的文字颜色 - (void)customizeInterface { // 普通状态下的文字属性 NSMutableDictionary *normalAttrs = [NSMutableDictionary dictionary]; normalAttrs[NSForegroundColorAttributeName] = [UIColor grayColor]; // 选中状态下的文字属性 NSMutableDictionary *selectedAttrs = [NSMutableDictionary dictionary]; selectedAttrs[NSForegroundColorAttributeName] = [UIColor orangeColor]; // 设置文字属性 UITabBarItem *tabBar = [UITabBarItem appearance]; [tabBar setTitleTextAttributes:normalAttrs forState:UIControlStateNormal]; [tabBar setTitleTextAttributes:selectedAttrs forState:UIControlStateSelected]; // 设置背景图片 UITabBar *tabBarAppearance = [UITabBar appearance]; [tabBarAppearance setBackgroundImage:[UIImage imageNamed:@"tabbar_background"]]; } @end 在需要添加的按钮类ComposeButton类中,实现的代码如下: ComposeButton.h文件: // ComposeButton.h // CYLTabBarController // // Created by mac on 16/1/28. // Copyright © 2016年 mac. All rights reserved. // #import <CYLPlusButton.h> @interface ComposeButton : CYLPlusButton<CYLPlusButtonSubclassing> @end ComposeButton.h文件: // ComposeButton.m // CYLTabBarController // // Created by mac on 16/1/28. // Copyright © 2016年 mac. All rights reserved. // #import "ComposeButton.h" @implementation ComposeButton +(void)load{ [super registerSubclass]; } +(instancetype)plusButton{ ComposeButton *composeButton = [[ComposeButton alloc]initWithFrame:CGRectMake(0, 0, 44, 44)]; //设置背景 [composeButton setBackgroundImage:[UIImage imageNamed:@"tabbar_compose_button"] forState:UIControlStateNormal]; [composeButton setBackgroundImage:[UIImage imageNamed:@"tabbar_compose_button_highlighted"] forState:UIControlStateHighlighted]; //设置按钮 [composeButton setImage:[UIImage imageNamed:@"tabbar_compose_icon_add"] forState:UIControlStateNormal]; [composeButton setImage:[UIImage imageNamed:@"tabbar_compose_icon_add_highlighted"] forState:UIControlStateSelected]; return composeButton; } //返回插入位置,因为是奇数,所以不用指定安放的位置,它会自动调整位置 //+ (NSUInteger)indexOfPlusButtonInTabBar{ // // return 2; //} @end 在发布控制器中实现的是代码:ComposeViewController.m // ComposeViewController.m // CYLTabBarController // // Created by mac on 16/1/28. // Copyright © 2016年 mac. All rights reserved. // #import "ComposeViewController.h" @interface ComposeViewController () @property (strong,nonatomic)UIToolbar *topToolBar; @end #define SCREEN_WIDTH [UIScreen mainScreen].bounds.size.width #define SCREEN_HEIGHT [UIScreen mainScreen].bounds.size.height @implementation ComposeViewController /** * 设置工具栏 */ -(void)viewWillAppear:(BOOL)animated{ [[UIToolbar appearance]setTintColor:[UIColor brownColor]]; self.topToolBar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 64)]; UIBarButtonItem *leftItem = [[UIBarButtonItem alloc]initWithTitle:@"返回" style:UIBarButtonItemStylePlain target:self action:@selector(leftItemBack:)]; UIBarButtonItem *flexItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil]; UIBarButtonItem *midItem = [[UIBarButtonItem alloc]initWithTitle:@"发布新微薄" style:UIBarButtonItemStylePlain target:nil action:nil]; [midItem setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor blackColor]} forState:UIControlStateNormal]; [midItem setEnabled:NO]; UIBarButtonItem *rightItem = [[UIBarButtonItem alloc]initWithTitle:@"发送" style:UIBarButtonItemStylePlain target:self action:@selector(rightItemSend:)]; self.topToolBar.items = @[leftItem,flexItem,midItem,flexItem,rightItem]; [self.view addSubview:self.topToolBar]; } - (void)viewDidLoad { [super viewDidLoad]; self.title = @"发布"; self.view.backgroundColor = [UIColor lightGrayColor]; } #pragma mark - 返回按钮事件,关闭模态的发布控制器 -(void)leftItemBack:(UIBarButtonItem *)sender{ [self.view.window.rootViewController dismissViewControllerAnimated:YES completion:nil]; } #pragma mark - 发布按钮事件,发布新的微博 -(void)rightItemSend:(UIBarButtonItem *)sender{ NSLog(@"%s",__func__); } @end 演示截图如下: 点击发布按钮时: 程序猿神奇的手,每时每刻,这双手都在改变着世界的交互方式! 本文转自当天真遇到现实博客园博客,原文链接:http://www.cnblogs.com/XYQ-208910/p/5166778.html ,如需转载请自行联系原作者

优秀的个人博客,低调大师

iOS:viewController 和 view 的生命周期、不错的代码设计风格

一、介绍: viwe和viewController的生命周期是最基本的知识,如果很好地理解它们的方法调用的执行顺序,就能很好地设计代码的风格。这篇博客转载自:http://www.cnblogs.com/peaceWang/p/5346726.html。有时间我会在此基础上完善,具体讲述一下每一个方法中最适合执行的操作。 控制器创建的生命周期 1. 如果从stroryBoard 中产生一个controller,那么会先调用initWithCoder:, awakeFromNib, loadView,viewDidLoad,viewWillAppear,viewWillLayoutSubviews,不会调用init方法。 2. 如果从代码中产生一个ViewController,那么会调用init方法,loadView,viewDidLoad,viewWillAppear,viewWillLayoutSubviews等 自定义view创建的生命周期 1. 如果是从nib中产生,那么会调用view的initWithCoder:,awakeFromNib,layouSubviews方法,不会调用initWithFrame: 方法 2. 如果代码产生,那么会调用view的init ,initWithFrame: ,layoutSubviews方法 控制器view的加载方式: 1. 调用loadView方法,如果实现的话进行调用,重写loadView方法,很容易造成错误,注意loadView的调用时机,loadView常用来手动添加view 2. 查找StoryBoard,看是否包含该控制器,如果有,加载storyBoard 中的view 3. 查找xib 文件,先查找该控制器名字Controller前面的字符串组成的名字的xib 文件,如果没有找到,那么查找与Controller 同名的xib 文件 4. 如果没有找到,那么系统产生一个空白的view 控制器和控制器自带的nib之间的关系: 1. 使用init 方法初始化conroller的时候,先调用initWithNib:bundle方法,然后是init方法,然后直接调用loadView方法,viewDidLoad,viewWillAppear,viewWillLayoutSubviews,viewDidLayoutSubviews,viewDidAppear等等方法,注意没有调用controller的initWithCoder:,awakeFromNib方法 。更正:我发现连当我自己调用loadView 方法时候,viewDidLoad都没有调用,然后在initWIthNib:bundle里面初始化相关的IB连接发现居然是无效的,我在viewDidLayouSubviews:方法中初始化时有效地;所以以后还是不要手动调用loadView方法了 2. 使用initWithNib:bundle方法初始化controller,不会调用init,然后直接调用loadView方法,viewDidLoad,viewWIllAppear,viewWillLayoutSubviews,viewDidLayoutSubviews,viewDidAppear等方法,不会调用controller的initWithCoder:,awakeFromNib等方法,这点很容易犯错 有时候只有一个xib自定义的view 添加到控制器view的时候,我们可以直接将该xib 作为控制器的view, 设置owner; 也可以在loadview中将新的view 赋值给viewController.view 二、view中不错的代码设计风格如下: View Code 三、viewController中不错的代码设计风格如下: View Code 程序猿神奇的手,每时每刻,这双手都在改变着世界的交互方式! 本文转自当天真遇到现实博客园博客,原文链接:http://www.cnblogs.com/XYQ-208910/p/6724438.html ,如需转载请自行联系原作者

优秀的个人博客,低调大师

iOS 防 DNS 污染方案调研 --- 302等 URL 重定向业务场景

概述 302等 URL 重定向业务场景需要解决的问题: 302 等重定向状态码,如何正确执行跳转逻辑,要求跳转后,依然需要执行 IP 直连逻辑,多次 302,也能覆盖到。 302等 URL 重定向业务场景问题主要集中在 POST 请求上,解决方案的方向大致有几种: 将请求方式统一替换为 GET 解决 POST 请求时的重定向问题 将 URL 统一替换为 GET,这种方案在客户端这边是成本最低的,如果团队中达成一致是最好的。不过限制也是显而易见的。那么我们就着重讨论下如何解决 POST 请求时的重定向问题。 POST 请求的重定向问题 对于 GET 请求,重定向问题较为简单,我们着重讨论下 POST 请求的重定向问题,看下不同状态码下的响应方式。 下面介绍下重定向的类型以及解释: 重定向的类型 对应协议 解释 300 Multiple Choices HTTP

资源下载

更多资源
优质分享App

优质分享App

近一个月的开发和优化,本站点的第一个app全新上线。该app采用极致压缩,本体才4.36MB。系统里面做了大量数据访问、缓存优化。方便用户在手机上查看文章。后续会推出HarmonyOS的适配版本。

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

用户登录
用户注册
修改密码
忘记密码