首页 文章 精选 留言 我的

精选列表

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

iOS开发-plist文件增删改查

plist第一次看到这个后缀名文件的时候感觉怪怪的,不过接触久了也就习以为常了,plist是Property List的简称可以理解成属性列表文件,主要用来存储串行化后的对象的文件。扩展名为.plist,因此被称为plist文件,xCode中默认的是一种树状的结构展现出来数据,可视化的动态增删改查,非常人性化,不过最终的结果是以XML形式存储的,Plist文件可以用于存储用户的一些设置信息,具体根据需求而定。 简单创建文件 简单创建文件就是说可以直接从xCode创建,右击项目new File,可以添加一个plist文件: 创建一个UserData.plist文件,之后的内容如下: 右击open as->source code,代码如下: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 <?xml version= "1.0" encoding= "UTF-8" ?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd" > <plist version= "1.0" > <dict> <key>Login</key> <dict> <key>UserName</key> <string>FlyElephant</string> <key>UserPassWord</key> <string>123456</string> </dict> </dict> </plist> 读取设置的信息: 1 2 3 4 5 6 //读取Property List文件 NSString *userDataPath = [[ NSBundle mainBundle] pathForResource:@ "UserData" ofType:@ "plist" ]; NSMutableDictionary *data = [[ NSMutableDictionary alloc] initWithContentsOfFile:userDataPath]; NSLog (@ "%@" ,data); NSLog (@ "用户名:%@ 密码:%@" , data[@ "Login" ][@ "UserName" ],data[@ "Login" ][@ "UserPassWord" ]); [data setObject:@ "登录信息" forKey:@ "Login" ]; 增删改查 文件添加,上面是应用程序中添加文件,这个时候可以选择代码在沙盒中添加,代码如下: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 NSArray *sandboxpath= NSSearchPathForDirectoriesInDomains ( NSDocumentDirectory , NSUserDomainMask , YES ); //获取完整路径 NSString *documentsDirectory = [sandboxpath objectAtIndex:0]; NSString *plistPath = [documentsDirectory stringByAppendingPathComponent:@ "sandbox.plist" ]; //存储根数据 NSMutableDictionary *rootDic = [[ NSMutableDictionary alloc ] init]; //字典中的详细数据 NSMutableDictionary *userDataDic = [[ NSMutableDictionary alloc]init]; [userDataDic setObject:@ "Flephant" forKey:@ "UserName" ]; [userDataDic setObject:@ "http://www.cnblogs.com/xiaofeixiang/" forKey:@ "UserPassWord" ]; [rootDic setObject:userDataDic forKey:@ "Login" ]; //写入文件 [rootDic writeToFile:plistPath atomically: YES ]; NSLog (@ "%@" , NSHomeDirectory ()); NSLog (@ "写入成功" ); 路径如下,具体路径获取上一篇文章已经可以看到: 读取数据: 1 2 3 4 5 6 7 //获取路径 NSArray *sandboxpath= NSSearchPathForDirectoriesInDomains ( NSDocumentDirectory , NSUserDomainMask , YES ); NSString *filePath = [[sandboxpath objectAtIndex:0] stringByAppendingPathComponent:@ "sandbox.plist" ]; NSLog (@ "%@" , NSHomeDirectory ()); //获取数据 NSMutableDictionary *searchdata = [[ NSMutableDictionary alloc] initWithContentsOfFile:filePath]; NSLog (@ "%@" ,searchdata); 修改文件: 1 2 3 4 5 6 7 8 9 10 11 12 13 //获取路径 NSString *filepath = [[ NSSearchPathForDirectoriesInDomains ( NSDocumentDirectory , NSUserDomainMask , YES )objectAtIndex:0]stringByAppendingPathComponent:@ "sandbox.plist" ]; //所有的数据列表 NSMutableDictionary *datalist= [[[ NSMutableDictionary alloc]initWithContentsOfFile:filepath]mutableCopy]; //获取Login节点 NSMutableDictionary *loginData = [datalist objectForKey:@ "Login" ]; [loginData setValue: @ "FlyElephant" forKey:@ "UserName" ]; [loginData setValue: @ "123456" forKey:@ "UserPassWord" ]; [datalist setValue:loginData forKey:@ "Login" ]; [datalist writeToFile:filepath atomically: YES ]; NSLog (@ "修改成功" ); 删除文件: 1 2 3 4 5 6 NSFileManager *manager=[ NSFileManager defaultManager]; //文件路径 NSString *filepath = [[ NSSearchPathForDirectoriesInDomains ( NSDocumentDirectory , NSUserDomainMask , YES )objectAtIndex:0]stringByAppendingPathComponent:@ "sandbox.plist" ]; if ([manager removeItemAtPath:filepath error: nil ]) { NSLog (@ "文件删除成功" ); } 本文转自Fly_Elephant博客园博客,原文链接:http://www.cnblogs.com/xiaofeixiang/p/4263498.html,如需转载请自行联系原作者

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

Android初级开发第九讲--动画

本文来自http://blog.csdn.net/liuxian13183/,引用必须注明出处! Android中动画的应用,在应用管理软件、购物软件、追星软件等比较广泛;比如常见的进度条设计,此处尤其指圆形的那种。比如清理小火箭,从下向上飞出;比如清理软件提示,由深色渐变成浅色。这些都是动画的应用场景。 Android动画分为两种,一种叫帧动画,就像flash一样,学名Frame,进度条一般使用这种;另一种叫补间动画,学名Tween,可以移动位置、变化颜色、变换大小、翻转变化。 先说帧动画 <?xml version="1.0" encoding="utf-8"?> <animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="false"> <item android:drawable="@mipmap/icon_s01" android:duration="30" /> <item android:drawable="@mipmap/icon_s02" android:duration="30" /> <item android:drawable="@mipmap/icon_s03" android:duration="30" /> </animation-list> onshot的意思是,true只播放一遍,false循环播放;item项指每隔duration展示的图片 应用: 先写布局 <ImageView android:id="@+id/loading_iv" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:background="@drawable/anim_progress_round"/> 再执行代码 ImageView loadingImage = child.findViewById(R.id.loading_iv); AnimationDrawable animation = (AnimationDrawable) loadingImage.getBackground(); if (animation.isRunning()) { animation.stop(); } animation.start(); 获得背景的AnimationDrawable对象,执行start方法即可。 补间动画: 基类Animation,子类ScaleAnimation、AlphaAnimation、RotateAnimation、TranlateAnimation,分别用于大小变换、色彩变换、翻转变换和位移变换。 常用方法有setDutation-设置运行时间,setFillAfter-设置运行结束是否保持最后状态,setFillBefore-设置运行结束是否保质最初状态,setRepeatCount-设置重复执行次数;setRepeatMode-设置重复类型,如REVERSE会倒着再执行repeatCount遍;setInterpolater-设置插补器,可以让控件回弹,控制速度。 //accelerate_decelerate_interpolator先慢后快再慢linear_interpolator匀速decelerate_interpolator先快后慢 mAnimationTranslate.setInterpolator(mContext, android.R.anim.decelerate_interpolator); 例: mAnimationTranslate = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0f, Animation.RELATIVE_TO_PARENT, 1, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0); mAnimationTranslate.setDuration(3000); mAnimationTranslate.setRepeatMode(Animation.ABSOLUTE); mAnimationTranslate.setRepeatCount(0); mRocketIv.startAnimation(mAnimationTranslate);设置相关参数,执行startAnimation即可。 ScaleAnimation:fromXScale-X轴方向缩放比例,toXScale、fromYScale和toYScale同理;pivoteX起点X坐标,pivoteY同理。 AlphaAnimation:fromAlpha-起始透明度,toAlpha-最终透明度。 RotateAnimation:fromDegress-起始角度,toDegress-最终角度,正数为顺时针,负数为逆时针。 TranslateAnimation:fromXType-起始位移类型,fromYType同理;fromXValue-起始X坐标,fromYValue同理; 从左边折出来 ScaleAnimation animation = new ScaleAnimation(0f, 1f, 1f, 1f); animation.setDuration(1000);//设置动画持续时间 mChannelLayout.setAnimation(animation); 从左上角弹出来 ScaleAnimation animation = new ScaleAnimation(0f, 1f, 0f, 1f); animation.setDuration(1000);//设置动画持续时间 mChannelLayout.setAnimation(animation); 从左向右的动画: AnimationUtils.makeInAnimation(this, true); 从右回到左的动画: AnimationUtils.makeOutAnimation(this, false); 最后AnimationSet可以对以上四种补间动画类型进行组合,制造出更加炫酷的效果。

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

iOS开发-图片查看(ScrollView+UIPageControl)

上周没事写了一个简单的图片查看,上次的查看只用到了一个UIImageView,不断的替换背景图片,实现图片之间的切换。通过ScrollView可以很简单的是实现图片之间的查看,设置setPagingEnabled通过坐标,宽度的设置,可以简单实现一个图片的简单分页查看显示,当然如果你有需求说需要进行所谓的无限循环,在开始和结束的时候的设置一下事件,常用的新闻客户端,图片新闻查看的时候很少有进行最后的时候跳到第一页,一般都是最后的时候都是推荐相关内容,多说了两句,开始吧: ScrollView图片分页 控件跟上篇文章一样,就是ScrollView: 拖入三张图片到项目中,之前的文章有演示,下次写博客的考虑换图,初始化ScrollView: 1 2 3 4 5 6 7 8 9 10 NSArray *imageArr=@[@ "girl0.jpg" ,@ "girl1.jpg" ,@ "girl2.jpg" ]; CGFloat width= self .scrollView.bounds.size.width; CGFloat height= self .scrollView.bounds.size.height; for ( NSInteger i=0; i<[imageArr count]; i++) { UIImage *image=[UIImage imageNamed:imageArr[i]]; UIImageView *imageView=[[UIImageView alloc] initWithImage:image]; [imageView setFrame:CGRectMake(i*width, 0, width, height)]; [_scrollView addSubview:imageView]; } 这里没有写注释,稍微多说一句就是bounds是边界,可以理解为就是控件中的ScrollView的宽度和高度,也就是上一张图片展示的宽度和高度,设置周围的边界: 1 [ self .scrollView setBounces: NO ]; 设置水平方向的滚动条: 1 [ self .scrollView setShowsHorizontalScrollIndicator: NO ]; 设置ScrollView的总体的宽度(关键): 1 [ self .scrollView setContentSize:CGSizeMake([imageArr count]*width, height)]; 设置分页: 1 [ self .scrollView setPagingEnabled: YES ]; 演示效果: UIPageControl和ScrollView图片分页 UIPageControl如果稍微弄过点前端可以理解为焦点图,大概通过指示,iOS中是小圆点,Android需要美工给自己切图或者说自力更生,iOS相对来说还是比较人性的,先定义一个UIPageControl: 1 @property ( nonatomic ,strong) UIPageControl *pageControl; 初始化UIPageControl设置大小和位置: 1 2 3 4 5 self .pageControl=[[UIPageControl alloc] init]; self .pageControl.backgroundColor=[UIColor clearColor]; [ self .pageControl setBounds:CGRectMake(0, 0,200, 100)]; [ self .pageControl setCenter:CGPointMake(width/2,height/2+200.0)]; 设置当前页和页大小: 1 2 self .pageControl.numberOfPages=[imageArr count]; self .pageControl.currentPage=0; 设置当前指示和其他指示: 1 2 3 [ self .pageControl setCurrentPageIndicatorTintColor:[UIColor greenColor]]; [ self .pageControl setPageIndicatorTintColor:[UIColor yellowColor]]; 设置滑动的时候改变UIPageControl和通过UIPageControl改变ScrollView: 1 2 3 [_scrollView setDelegate: self ]; [ self .pageControl addTarget: self action: @selector (switchPage:) forControlEvents:UIControlEventValueChanged]; [ self .view addSubview:_pageControl]; 滑动的时候改变UIPageControl指示通过委托设置,具体可参考上篇文章: 1 2 3 4 -( void )scrollViewDidEndDecelerating:(UIScrollView *)scrollView{ NSInteger currentPage=scrollView.contentOffset.x/ self .view.bounds.size.width; [ self .pageControl setCurrentPage:currentPage]; } UIPageControl改变ScrollView: 1 2 3 4 5 - ( void )switchPage:( id )sender{ UIPageControl *currentControl=(UIPageControl *)sender; NSInteger currentPage=currentControl.currentPage; [_scrollView setContentOffset:CGPointMake(currentPage* self .view.bounds.size.width, 0)] ; } 看下具体的效果: 本文转自Fly_Elephant博客园博客,原文链接:http://www.cnblogs.com/xiaofeixiang/p/4242919.html,如需转载请自行联系原作者

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

Android开发学习笔记:浅谈DDMS视图

DDMS 的全称是Dalvik Debug Monitor Service,即Dalvik调试监控服务,是一个可视化的调试监控工具。它主要是对系统运行后台日志的监控,还有系统线程,模拟器状态的监控。此外,它还可以模拟收发短信,拨打电话和发送GPS位置信息等。 在eclipse中启动DDMS 1.在eclipse界面的右上角,点击,出现下面的界面 2.选择other,这时界面如下图所示,双击DDMS就可以启动 DDMS各部分组成的功能简介 1.Devices 可以查看到所有与DDMS连 接的模拟器详细信息,以及每个模拟器正在运行的APP进程,每个进程最右边相对应的是与调试器链接的端口。 2.Emulator Control可以实现对模拟器的控制,比如:接听电话,根据选项模拟各种不同网络情况,模拟接受SMS消息和发送虚拟地址坐标用于测试GPS功能等。 Telephony Status:通过选项模拟语音质量以及信号连接模式。 Telephony Actions:模拟电话接听和发送SMS到测试终端。 Location Control:模拟地理坐标或者模拟动态的路线坐标变化并显示预设的地理标识,可以通过以下3种方式: (1)Manual:手动为终端发送二维经纬坐标。 (2)GPX:通过GPX文件导入序列动态变化地理坐标,从而模拟行进中GPS变化的数值。 (3)KML:通过KML文件导入独特的地理标识,并以动态形式根据变化的地理坐标显示在测试终端。 3.LogCat主要输出模拟器的一些信息 4.Filter功能类似过滤器,能过滤一些调试的信息 5. V:输出所有的信息 D:输出Debug信息 I:输出info信息 W:输出警告信息 E:输出错误的信息 :能删除当前LogCat输出的信息 6.Threads、Heap、File Exporler,最常用的就是File Exporler文件浏览器,通过File Exporler可以查看Android模拟器中的文件,可以很方便的导入/出文件。 本文转自 lingdududu 51CTO博客,原文链接: http://blog.51cto.com/liangruijun/631061

资源下载

更多资源
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应用均可从中受益。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

用户登录
用户注册