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. SVA(system verilog assertions)基础

    1什么是断言: 断言就是在模拟过程中依据我们事先安排好的逻辑是不是发生了,假设发生断言成功.否则断言失败. 2断言的运行分为:预备(preponed)观察(observed)响应(reactive). ...

  2. zoj 3288 Domination (可能dp)

    ///dp[i][j][k]代表i行j列件,并把一k的概率 ///dp[i][j][k]一种常见的方法有四种传输 ///1:dp[i-1][j][k-1] 可能 (n-(i-1))*j/(n*m-(k ...

  3. 让Android系统支持ubifs文件系统

    原文地址:http://www.cnblogs.com/linucos/p/3279381.html 1. ubifs号称性能比yaffs2 好,同时压缩可读写,文件系统image体较小同时可写,相当 ...

  4. JS弄ASP.NET(C#)在页GridView信息选择行

    做web发展还是新手我,为了之前获得Gridview中间值,它是通过服务器端控件通过第一Gridview将数据保存到服务器,当一个服务器,然后绑定的隐藏字段,在通过的js阅读隐藏字段值,如今,这种方法 ...

  5. Oracle游标(光标)

     watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdGFuZ2xpdXFpbmc=/font/5a6L5L2T/fontsize/400/fill/I0J ...

  6. 1!到n!的和

    Time Limit: 1 Sec  Memory Limit: 64 MB Submit: 23  Solved: 14 [Submit][Status][Web Board] Descriptio ...

  7. Namespace:Openstack的网络实现

    前言:众所周知在linux系统中PID.IPC.Network等都是全局性的资源,不论什么的改动和删减都会对整个系统造成影响.这也是为什么kvm之类的虚拟化技术须要模拟一个完毕主机系统的原因. 可是. ...

  8. DM8168 新三板系统启动

    DM8168从补丁到系统的新董事会开始折腾了20天,最终完成,高校是累的东西,导师只焊接机10一个BGA,其他人则手. 前段时间启动操作系统时,到了Starting Matrix GUI applic ...

  9. Spring MVC框架搭建

    Spring MVC篇一.搭建Spring MVC框架 本项目旨在搭建一个简单的Spring MVC框架,了解Spring MVC的基础配置等内容. 一.项目结构 本项目使用idea intellij ...

  10. How use Instruments and display the console in Command Lines applications

    I'm using Xcode on OSX to develop command line C applications. I would also like to use Instruments ...