IOS View传统的价值观之间
1、采用NSUserDefaults通过值,这样的方法不限于传送少量数据的:
比方你要传一个float的值。在须要传的时候用
[[NSUserDefaults standardUserDefaults] setFloat:float forKey::@"float"]
接收值的时候用
[[NSUserDefaults standardUserDefaults] floatForKey:@"float"]
2、NSNotificationCenter来传值
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch * touch = [touches anyObject];
CGPoint point = [touch locationInView:self];
CGRect roundRect = [self rectNeedRefreshFromThisPoint:point];
mLastPoint = CGPointMake(-1, -1);
NSLog(@"%s: point(%f,%f)", __FUNCTION__, point.x, point.y);
[self addToCurrentLineWithPoint:point.x y:point.y];
[self endLine];
[self setNeedsDisplayInRect:roundRect];
NSNumber *pointX = [NSNumber numberWithFloat:point.x];
NSNumber *pointY = [NSNumber numberWithFloat:point.y];
NSDictionary *pointDict = [NSDictionary dictionaryWithObjectsAndKeys:pointX,@"pointX",pointY,@"pointY", nil];
[[NSNotificationCenter defaultCenter]postNotificationName:@"passTouchedEndPointMsg"object:self userInfo:pointDict];
}
在消息中心的函数:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(getTouchedPoint:)
name:@"passTouchedEndPointMsg"
object:nil];
- (void) getTouchedPoint:(NSNotification *)noti
{
NSDictionary *pointDict = [noti userInfo];
touchedEndPointX = [[pointDict objectForKey:@"pointX"] floatValue];
touchedEndPointY = [[pointDict objectForKey:@"pointY"] floatValue];
NSLog(@"%f:%f",touchedEndPointX,touchedEndPointY);
}
用消息来传參数有以下几点说法:object指的是发送者、在poseter端的userInfo里面能够存放要传的參数,必须为NSDictionary类型。在center端获取这个dictionary类型用:[notification userInfo];要得到
版权声明:本文博主原创文章,博客,未经同意不得转载。
IOS View传统的价值观之间的更多相关文章
- iOS开发拓展篇—应用之间的跳转和数据传递
iOS开发拓展篇—应用之间的跳转和数据传 说明:本文介绍app如何打开另一个app,并且传递数据. 一.简单说明 新建两个应用,分别为应用A和应用B. 实现要求:在appA的页面中点击对应的按钮,能够 ...
- IOS 计算两个经纬度之间的距离
IOS 计算两个经纬度之间的距离 一 丶 -(double)distanceBetweenOrderBy:(double) lat1 :(double) lat2 :(double) lng1 :(d ...
- iOS View 模糊效果(毛玻璃)
iOS View 模糊效果(毛玻璃) 相关资料 http://stackoverflow.com/questions/18404907/using-gpuimage-to-recreate-ios ...
- ios View 向上拉界面源码
如下的资料是关于ios View 向上拉界面的代码. #pragma mark - 上升效果- (void)ToUpSide { } - (void)moveToUpSide { ...
- iOS自定义组与组之间的距离以及视图
iOS自定义组与组之间的距离以及视图 //头视图高度 - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(N ...
- ios View之间的切换 屏幕旋转
6.3 View之间的切换 在上面的练习中我们通过移动组件的位置和调整组件的大小来处理横向与纵向的界面布局.但是在界面中有很多组件的时候,对每个组件都进行这样的操作确实是一个麻烦的事情.下面我们看看 ...
- 【转】IOS屏幕旋转与View的transform属性之间的关系,比较底层
iTouch,iPhone,iPad设置都是支持旋转的,如果我们的程序能够根据不同的方向做出不同的布局,体验会更好. 如何设置程序支持旋转呢,通常我们会在程序的info.plist中进行设置Suppo ...
- iOS基本控制-UINavigationController 传统的价值观,代理传统价值观,正向传统价值观,反传统的价值观
/* 程序过程: 1.创建一个根视图,一个二级视图 2,根视图NavigationItem.title = Root 二级视图NavigationItem.title = Secon ...
- IOS - view之间切换
//进入下一页 - (IBAction)Go:(id)sender { TwoViewController *twoVC = [[TwoViewController alloc] init];//这里 ...
随机推荐
- s3c2440的A/D转换应用
10 地点 CMOS ADC(模/数字转换器)是 8 通道模拟输入型设备回收.该模拟输入信号转换 10 位二进制数字编码,A/D变化.也被称为模数转换.该模拟信号被转换成美元 算机可以处理的数字信号. ...
- MVC快速分页
.NET手记-ASP.NET MVC快速分页的实现 对于Web应用,展示List是很常见的需求,随之而来的常见的分页组件.jQuery有现成的分页组件,网上也有着大量的第三方分页组件,都能够快速实 ...
- Android游戏源代码合集(主要是AndEngine和Libgdx的)
近期在网络上看到有网友抱怨Android游戏源代码找不到,所以小弟收集了一些AndEngine和Libgdx的游戏源代码,以Eclipseproject的形式配置好环境,再陆续发出(某引擎避嫌,不在此 ...
- 关于js中window.location.href,location.href,parent.location.href,top.location.href的使用方法
关于js中"window.location.href"."location.href"."parent.location.href".&qu ...
- 【6】和作为连续序列s
称号:输入一个整数s,并打印出所有s整数的连续序列(含有至少2的数量). 如输入9,输出2.3.4和4.5两个序列 方案一:因为序列至少要2个数,则两个数上限值为(1+s)/2,我们能够枚举该序列的起 ...
- (五岁以下儿童)NS3样本演示:桥模块演示样品csma-bridge.cc凝视程序
(五岁以下儿童)NS3:桥模块演示样品csma-bridge.cc凝视程序 1.Ns3 bridge模csma-bridge.cc演示示例程序的目光 // Network topology // // ...
- SQL Server 版本号汇总
通过SSMS连接Sql servr,查看实例的版本就能知道当前SQL Server的版本号了. RTM (no SP) SP1 SP2 SP3 SP4 SQL Server 2014 c ...
- 编程算法 - 最小的k个数 红黑树 代码(C++)
最小的k个数 红黑树 代码(C++) 本文地址: http://blog.csdn.net/caroline_wendy 题目: 输入n个整数, 找出当中的最小k个数. 使用红黑树(multiset) ...
- 使用 node-inspector 调试 Node.js
大部分基于 Node.js 的应用都是执行在浏览器中的, 比如强大的调试工具 node-inspector. node-inspector 是一个全然基于 Node.js 的开源在线调试工具,提供了强 ...
- 纯 Swift 封装的 SQLite 框架:SQLite.swift
SQLite.swift 是一个使用纯 Swift 语言封装 SQLite3 的操作框架. 特性: 简单的查询和参数绑定接口 安全.自动类型数据访问 隐式提交和回滚接口 开发者友好的错误处理和调试 文 ...