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. Embedding Lua, in Scala, using Java(转)

    LuaJ I was reading over the list of features that CurioDB lacks compared to Redis , that I’d previou ...

  2. SDL 简单入门学习

    write by 九天雁翎(JTianLing) -- blog.csdn.net/vagrxie 讨论新闻组及文件 概要 实际学习使用SDL创建窗体,并绘制图形. 前言 今天想要做一个简单的demo ...

  3. sizeClass和autolayout学习资源整理

    sizeClass和autolayout,看来不得不開始放弃frame的写法,收集点资料集中学习下 Adaptivity User Interfaces苹果官方文档:https://developer ...

  4. client多线程

    1.多线程对象 对象可以是多线程访问,线程可以在这里分为两类: 为完成内部业务逻辑的创建Thread对象,线程需要访问对象. 使用对象的线程外部对象. 进一步假设更精细的划分.业主外螺纹成线等线,. ...

  5. 对于Netty的十一个疑问(转)

    [说明]本文原载于码农 IO(manong.io)官方微信 developerWorks,转载.引用请注明出处及作者. 1.Netty 是什么? Netty 是一个基于 JAVA NIO 类库的异步通 ...

  6. 如何解决vector 析构函数的异常 opencv Assert _CrtIsValidHeapPointer

    一气呵成代码,但是,当发生执行_CrtIsValidHeapPointer例外,去搭调了一上午Bug.最终获得 跟踪定位到 _CrtIsValidHeapPointer ,注意到 g 8h&quo ...

  7. Web指纹识别目的Discuz识别+粗糙的版本演绎

    这个识别程序是本学期在我的职业培训项目.它是做一类似至Zoomeye怪东西,然后使用ES集成,为了让搜索引擎寻找.因此,我们必须首先去网上识别相应的能力Web包裹,如果用户输入的关键词:Discuz ...

  8. 利用hibernate的session查询数据库,而且在jsp页面显示表内容的方法

    试过了非常多种方法都没有成功,最终让我找到了这样的方法! 首先在后台写代码: Transaction tx = session.beginTransaction(); List list = sess ...

  9. w3wp占用CPU过高

    w3wp占用CPU过高 在此之前项目有发生过两次类似的状况,都得以解决,但最近又会发现偶尔CPU会跑满,虽然之前使用过WinDbg解决过两次问题但人的记忆是不可靠的,今天处理同样问题的时候还是遇到了一 ...

  10. RH253读书笔记(2)-Lab 2 System Resource Access Controls

    Lab 2 System Resource Access Controls Goal: To become familiar with system resource access controls. ...