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传统的价值观之间的更多相关文章

  1. iOS开发拓展篇—应用之间的跳转和数据传递

    iOS开发拓展篇—应用之间的跳转和数据传 说明:本文介绍app如何打开另一个app,并且传递数据. 一.简单说明 新建两个应用,分别为应用A和应用B. 实现要求:在appA的页面中点击对应的按钮,能够 ...

  2. IOS 计算两个经纬度之间的距离

    IOS 计算两个经纬度之间的距离 一 丶 -(double)distanceBetweenOrderBy:(double) lat1 :(double) lat2 :(double) lng1 :(d ...

  3. iOS View 模糊效果(毛玻璃)

    iOS View 模糊效果(毛玻璃)   相关资料 http://stackoverflow.com/questions/18404907/using-gpuimage-to-recreate-ios ...

  4. ios View 向上拉界面源码

    如下的资料是关于ios View 向上拉界面的代码. #pragma mark - 上升效果- (void)ToUpSide {          } - (void)moveToUpSide {   ...

  5. iOS自定义组与组之间的距离以及视图

    iOS自定义组与组之间的距离以及视图 //头视图高度 - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(N ...

  6. ios View之间的切换 屏幕旋转

    6.3  View之间的切换 在上面的练习中我们通过移动组件的位置和调整组件的大小来处理横向与纵向的界面布局.但是在界面中有很多组件的时候,对每个组件都进行这样的操作确实是一个麻烦的事情.下面我们看看 ...

  7. 【转】IOS屏幕旋转与View的transform属性之间的关系,比较底层

    iTouch,iPhone,iPad设置都是支持旋转的,如果我们的程序能够根据不同的方向做出不同的布局,体验会更好. 如何设置程序支持旋转呢,通常我们会在程序的info.plist中进行设置Suppo ...

  8. iOS基本控制-UINavigationController 传统的价值观,代理传统价值观,正向传统价值观,反传统的价值观

    /*        程序过程:  1.创建一个根视图,一个二级视图  2,根视图NavigationItem.title = Root 二级视图NavigationItem.title = Secon ...

  9. IOS - view之间切换

    //进入下一页 - (IBAction)Go:(id)sender { TwoViewController *twoVC = [[TwoViewController alloc] init];//这里 ...

随机推荐

  1. cocos2d之Box2D详细说明 鼠标联合实现

    cocos2d之Box2D具体解释 鼠标关节实现 DionysosLai2014-5-7 我们常常要移动物理世界中的某个物体,例如说石头.木块等.假设我们直接改变这些物体的位置,让这些物体尾随我们手指 ...

  2. POJ2239 Selecting Courses【二部图最大匹配】

    主题链接: http://poj.org/problem?id=2239 题目大意: 学校总共同拥有N门课程,而且学校规定每天上12节可,一周上7天. 给你每门课每周上的次数,和哪一天哪一节 课上的. ...

  3. poj 1962 Corporative Network

    主题链接:http://poj.org/problem?id=1962 思路:每一个集合中用根节点标记这个集合,每一个点到根节点的距离. code: <span style="font ...

  4. String和StringBuffer 常用方法总结

     String和StringBuffer 常用方法总结 一.不可变长度String 1.字符串---->char数组 char[] chars=str.toCharArray(); 2.字符串中 ...

  5. C++习题 对象数组求最大值

    Description 建立一个对象数组,内放n(<10)个学生的数据(学号.成绩),设立一个函数max,用指向对象的指针作函数参数,在max函数中找出n个学生中成绩最高者,并输出其学号. In ...

  6. C3P0具体的配置说明(com.mchange.v2.c3p0.ComboPooledDataSource)

    C3P0它是一个开源JDBC连接池,它lib文件夹和Hibernate一起公布,包含了实现jdbc3和jdbc2扩展规范说明的Connection 和Statement 池的DataSources 对 ...

  7. HDFS建筑与shell操作

    一个.hadoop1.1.0演示 hadoop它适合于大容量数据存储和分布式计算平台 hadoop核心由hdfs和mapreduce组成 hdfs这是一个主从结构,仅有一个.是namenode:从节点 ...

  8. axWindowsMediaPlayer1获取音频长度

    OpenFileDialog openFileDialog1 = new OpenFileDialog { InitialDirectory = "c:\\", Filter = ...

  9. 11gR2 Database Services for &quot;Policy&quot; and &quot;Administrator&quot; Managed Databases (文件 ID 1481647.1)

    In this Document   _afrLoop=1459311711568804&id=1481647.1&displayIndex=6&_afrWindowMode= ...

  10. Chapter 1 Securing Your Server and Network(10):使用扩展保护避免授权中继攻击

    原文:Chapter 1 Securing Your Server and Network(10):使用扩展保护避免授权中继攻击 原文出处:http://blog.csdn.net/dba_huang ...