首页 文章 精选 留言 我的

精选列表

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

阅读阿里巴巴Java开发手册的持续感悟中。。。。。。

1.尽量少用if......else超过三层的if......else 尽量采用卫语句替代,就是if(condition){....... return; } 对于多层循环的优化多采用短路做法,就是直接空了怎么办,然后没空就是执行, 2.对于在集合中删除元素也是常见的那么怎么处理效率会更高呐, Iterator<String> iterator=list.iterator(); while(iterator.hasNext()){ String item = iterator.next(); if(删除元素的条件){ iterator.remove(); } } 3.我又了解到了,为什么有了数组还要有集合呐,是这样的,数组是顺序结构,集合里有顺序结构也有链式结构选择时好选择, 4.Arrays.asList()把数组转变为集合时,不能使用其修改集合相关的方法,它的add/remove/clear会抛出异常 因为asList的返回对象是一个Arrays内部类,并没有实现集合的修改方法,其体现的是适配器模式,只是转换接口后台的 数据仍是数组 如String[] str = new String[]{"you","wu"}; List list = Arrays.asList(str); str[0] = "guiji";那么list.get(0)也会随之改变 持续更新中。。。。。。

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

iOS组件化开发一远程私有库的升级(三)

一、远程私有库的升级 1、 把新增的类 拖入到 classes 文件夹中 ; 2、 修改 pod.spec 文件的 s.verson = ‘0.2.0'; 二、更新远程仓库 1、cd 到本地仓库的位置,执行以下操; 2、上传更新代码 git add . git commit -m '更新描述' git push origin master 3、版本更新这一步非常重要,为更新索引库做准备 //版本号要与 s.verson = ‘0.2.0'保持一致 git tag -a '新版本号' -m '注释' git push --tags 四、验证远程Spec //如果报错可能是你的文件错误,上传的时候一定要交验文件没有错误 pod spec lint —private 1、终端输出表示没有错误 2、远程索引库中有你的版本 五、更新远端和本地索引库 //pod repo push 索引库名称 xxx.podspec pod repo push gitee-peter_zhang-mobilekitspec MobileKit.podspec 六、搜索下库pod search MobileKit pod search MobileKit 1、如果本地出现所有的新版本和旧版本就表示成功 2、pod search: 如果没有搜到 可以尝试一下操作 rm ~/Library/Caches/CocoaPods/search_index.json 七、团队协作用法 1、找到本地的podfile文件更改成最新版本0.3.0 #pod默认源 source 'https://github.com/CocoaPods/Specs.git' source 'https://gitee.com/peter_zhang/MobileKitSpec.git' #平台工程版本 platform :ios, '8.0' target 'Ruter' do #消除警告 inhibit_all_warnings! #网络请求(warning~~ acceptableContentTypes加入@"text/html") pod 'AFNetworking', '~> 3.1.0' pod 'MobileKit', '~> 0.3.0' end 2、 然后cd到podfile所在文件目录执行 pod install 然后看到控制台输出表示安装成功

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

Linux(乌班图 )系统下安装jdk 和eclipse开发IDE

 自己在安装过程中遇到的一些坑记录下来,以及自己的安装过程做记录 1、下载jdk , jdk-8u144-linux-x64.tar.gz 2.下载 eclipse, eclipse-jee-mars-2-linux-gtk-x86_64.tar.gz 3.将jdk解压到 /usr/local/文件夹中 操作步骤: sudo tar zxvf jdk-8u144-linux-x64.tar.gz 4.配置jdk的环境变量,打开 /etc/profile文件(sudo vim /etc/profile),在文件末尾添加下语句: export JAVA_HOME=/usr/local/jdk1.8.0_144/ export JRE_HOME=${JAVA_HOME}/jre export JAVA_BIN=$JAVA_HOME/bin export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin 保存后退出。 使其立即生效:sudo source /etc/profile 查看是否安装成功:java -version 出现 java version "1.8.0_144" Java(TM) SE Runtime Environment (build 1.8.0_144-b01) Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode) 到此时,你在随意打开一个shell窗口,执行java -version命令,如果出现下面的内容,请不要按照提示进行安装 rootzhi@ubuntu:~/opt$ java -version The program 'java' can be found in the following packages: * default-jre * gcj-4.9-jre-headless * gcj-5-jre-headless * openjdk-8-jre-headless * gcj-4.8-jre-headless * openjdk-9-jre-headless Try: sudo apt install <selected package> 这里提示缺少安装包执行命令,但是请不要这么做! sudo apt-get install openjdk-6-jre-headless 5、这是因为乌班图默认安装了OpenJD看,我们想用自己的jdk,不需要默认,所以保险起见,在多执行一步命令,不管有还是没有openJdk先卸载 执行命令 sudo apt-get remove openjdk* 这条命令会卸载所有关于openjdk的东西,卸载的很干净,这样就可以在命令行下使用你自己的java版本了 设置默认jdk(假如有openjdk的话) 由于Ubuntu中可能会有默认的jdk,如openjdk。假如有openjdk的话,所以,为了使默认使用的是我们安装的jdk,还要进行如下工作(可以使用该命令安装其他命令,例如 eclipse)。 执行代码: sudo update-alternatives --install /usr/bin/java java /usr/local/jdk1.8.0_144/bin/java 300 sudo update-alternatives --install /usr/bin/javac javac /usr/local/jdk1.8.0_144/bin/javac 300 通过这一步将我们安装的jdk加入java选择单。 然后执行代码: sudo update-alternatives --config java sudo update-alternatives --config javac 6、最后到etc/目录下,在执行一次 source profile命令 7.安装 eclipse 将其解压到/opt/文件夹中 sudo tar zxvf eclipse-jee-mars-2-linux-gtk-x86_64.tar.gz -C /home/rootzhoukai/opt/ 8.创建eclipse桌面快捷方式图标。 cd 桌面乌班图Desktop目录 sudo touch eclipse.desktop sudo vim eclipse.desktop 输入以下内容: [Desktop Entry] Encoding=UTF-8 Name=Eclipse Coment=Eclipse Exec=/home/rootzhoukai/opt/eclipse/eclipse Icon=/home/rootzhoukai/opt/eclipse/icon.xpm Terminal=false StartupNotify=true Categories=Application;Development; 保存。 执行:sudo chmod u+x eclipse.desktop 将其变为可执行文件. 在桌面打开 eclipse ,结果提示没有安装JDK,JRE环境,明明我们安装过。 解决方法:在/opt/eclipse/文件夹中创建一个指向JRE路径的软链接。 sudo ln -sf $JRE_HOME jre 到此eclipse就全部安装完!

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

iOS开发实战 - 完美解决UIScrollView嵌套滑动手势冲突

我们应该都有用过这个功能,你的朋友微信给你分享了一个淘宝里面的商品链接,然后当你复制这个链接打开淘宝APP的时候,就会弹出一个弹窗,像这样: example.PNG 这个功能想必大家都挺熟悉,受这个启发我们产品也想在我们APP上添加这样一个功能,与这个不一样的是,当我们复制一段网址的时候打开我们的APP会弹出框填一些信息后上传到我们的“资源库”。大体功能就这样,所以记录一下实现的过程。 一、弹窗视图功能 .h中:两个信号一个是确定信号一个是取消信号 两个方法,一个显示一个隐藏方法 1 2 3 4 5 @property(nonatomic,strong)RACSubject*uploadSureSignal; //确定上传信号 @property(nonatomic,strong)RACSubject*hideSucSignal; //隐藏 -( void )show; -( void )hide; .m中:主要是两个textview,还有涉及到在keywindow上,IQKeyboard的一些操作 1 2 3 @property(nonatomic,assign)CGFloatkeyboardHeight; //键盘高度 @property(nonatomic,strong)CustomUITextView*nameTV; @property(nonatomic,strong)CustomUITextView*desTV; 因为发现IQKeyboard在这个弹出界面有问题,所以在显示这个界面的时候,将IQKeyboard禁用取之使用系统的keyboard监听方法 在(void)show方法中: 1 2 3 4 5 6 7 8 -( void )show{ //键盘通知 NSNotificationCenter*defaultCenter=[NSNotificationCenterdefaultCenter]; [defaultCenteraddObserver:selfselector:@selector(keyboardWillShowOrHide:)name:UIKeyboardWillShowNotificationobject:nil]; [defaultCenteraddObserver:selfselector:@selector(keyboardWillShowOrHide:)name:UIKeyboardWillHideNotificationobject:nil]; } 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 //监听方法 -( void )keyboardWillShowOrHide:(NSNotification*)notification{ //获取通知名 NSString*notificationName=notification.name; //获取通知内容 NSDictionary*keyboardInfo=notification.userInfo; //键盘弹出时,让画面整体稍稍上移,并伴随动画 //键盘回收时反之 CGRectkeyboardFrame=[notification.userInfo[UIKeyboardFrameEndUserInfoKey]CGRectValue]; CGFloatheight=keyboardFrame.size.height; self.keyboardHeight=height; //动画结束后self.view的frame值 CGRectselfViewFrame=self.bgView.frame; //通过通知名字判断弹出还是回收 if ([notificationNameisEqualToString:UIKeyboardWillShowNotification]){ selfViewFrame.origin.y=SCREEN_HEIGHT-PANELHEIGHT-height; } else { selfViewFrame.origin.y=SCREEN_HEIGHT-PANELHEIGHT; } //取出动画时长 NSTimeIntervalduration=[keyboardInfo[UIKeyboardAnimationDurationUserInfoKey]doubleValue]; //使用动画更改self.view.frame [UIViewanimateWithDuration:durationanimations:^{ //这里填入一些view的最终状态属性设置,即会自动产生过渡动画 self.bgView.frame=selfViewFrame; }]; } 同时在show方法中显示keyWindow,进而改变界面的frame进行显示 1 2 3 4 5 6 7 8 9 10 -( void )show{ UIWindow*keyWindow=[UIApplicationsharedApplication].keyWindow; [keyWindowaddSubview:self]; CGRectframe=self.bgView.frame; if (frame.origin.y==SCREEN_HEIGHT){ frame.origin.y=SCREEN_HEIGHT-PANELHEIGHT; [UIViewanimateWithDuration: 0.4 animations:^{ self.bgView.frame=frame; }]; } hide方法这里要考虑到键盘弹出后将self.bgView向上提高后frame的变化。 1 2 3 4 5 6 7 8 9 10 11 12 13 CGRectselfFrame=self.bgView.frame; if (selfFrame.origin.y==SCREEN_HEIGHT-PANELHEIGHT||selfFrame.origin.y==SCREEN_HEIGHT-PANELHEIGHT-self.keyboardHeight){ [selfresignFirstResponder]; selfFrame.origin.y=SCREEN_HEIGHT; [UIViewanimateWithDuration: 0.4 animations:^{ self.bgView.frame=selfFrame; }completion:^(BOOLfinished){ [IQKeyboardManagersharedManager].enable=YES; [[NSNotificationCenterdefaultCenter]removeObserver:self]; //[self.hideSucSignalsendNext:nil]; [selfremoveFromSuperview]; }]; } delegate中的操作 这里首先要弄懂APPdelegate中的这几个代理方法的意思: 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 //App已经启动 -(BOOL)application:(UIApplication*)applicationdidFinishLaunchingWithOptions:(NSDictionary*)launchOptions{ //Overridepointforcustomizationafterapplicationlaunch. return YES; } //App挂起状态 -( void )applicationWillResignActive:(UIApplication*)application{ //Sentwhentheapplicationisabouttomovefromactivetoinactivestate.Thiscanoccurforcertaintypesoftemporaryinterruptions(suchasanincomingphonecallorSMSmessage)orwhentheuserquitstheapplicationanditbeginsthetransitiontothebackgroundstate. //Usethismethodtopauseongoingtasks,disabletimers,andinvalidategraphicsrenderingcallbacks.Gamesshouldusethismethodtopausethegame. } //APP进入后台 -( void )applicationDidEnterBackground:(UIApplication*)application{ //Usethismethodtoreleasesharedresources,saveuserdata,invalidatetimers,andstoreenoughapplicationstateinformationtorestoreyourapplicationtoitscurrentstateincaseitisterminatedlater. //Ifyourapplicationsupportsbackgroundexecution,thismethodiscalledinsteadofapplicationWillTerminate:whentheuserquits. } //APP将重新回到前台 -( void )applicationWillEnterForeground:(UIApplication*)application{ //Calledaspartofthetransitionfromthebackgroundtotheactivestate;hereyoucanundomanyofthechangesmadeonenteringthebackground. } //APP进入活跃状态 -( void )applicationDidBecomeActive:(UIApplication*)application{ //Restartanytasksthatwerepaused(ornotyetstarted)whiletheapplicationwasinactive.Iftheapplicationwaspreviouslyinthebackground,optionallyrefreshtheuserinterface. } //系统时间发生改变时执行 -( void )applicationWillTerminate:(UIApplication*)application{ //Calledwhentheapplicationisabouttoterminate.Savedataifappropriate.SeealsoapplicationDidEnterBackground:. } 在上面的这些代理方法中,我们需要用到的是 applicationDidBecomeActive方法。在这个方法中我们去检查系统的粘贴板UIPasteboard *pasteboard = [UIPasteboard generalPasteboard]; 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 if (pasteboard.string){ NSLog(@ "string:%@" ,pasteboard.string); NSString*urlStr=pasteboard.string; if ([urlStrhasPrefix:@ "https://" ]||[urlStrhasPrefix:@ "http://" ]){ //如果粘贴板中的字符串包含https或http字段,我们去检查当前的控制器如果当前的控制器是我们弹出做操作的控制器的话isPopVC=NO; BOOLisPopVC=NO; UIViewController*Rootvc=self.window.rootViewController; if ([RootvcisKindOfClass:[UINavigationController class ]]){ UINavigationController*nav=(UINavigationController*)Rootvc; UIViewController*v=[nav.viewControllerslastObject]; if ([visKindOfClass:[UploadResCofingVC class ]]){ isPopVC=YES; } } //如果popView==nil并且isPopVC==NO弹出popView弹窗视图进行操作 if (!self.popView&&!isPopVC){ UploadResourcesPopupView*popView=[UploadResourcesPopupView new ]; [popViewshow]; self.popView=popView; [self.popView.hideSucSignalsubscribeNext:^(idx){ @strongify(self); self.popView=nil; }]; } } } } 总结 以上大体就是实现这个功能的基本思路,细节方面因项目而异了,比如我们需要判断当前用户的角色,当前用户是否登录,对弹窗视图后续的一些操作。当然并不完美,欢迎批评指正。 转自:http://www.cocoachina.com/ios/20180508/23307.html

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

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等操作系统。

用户登录
用户注册