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];//这里 ...
随机推荐
- 高级项目 它 集群环境建设(两)MySQL簇
最后博文我们介绍一下相关概念集群,今天我们要介绍的博文MySQL相关内容集群. 1.MySQL集群简单介绍 MySQL群集技术在分布式系统中为MySQL数据提供了冗余特性,增强了安全性,使得单个MyS ...
- quick 2.23 它们的定义c++代码lua与总结的一些细节
它们的定义c++代码lua与总结的一些细节 参考:点击打开链接 1.自己定义 XXX.cpp .XXX.h 2.D:\quick\quick-cocos2d-x-2.2.3-rc\lib\cocos2 ...
- 使用 Cordova+Visual Studio 创建跨平台移动应用(1)
1简介 本章节是关于Visual Studio Tools for Apache Cordova的,目前此产品只发布了预览版.Visual Studio for Apache Cordova帮助熟悉V ...
- [LeetCode160]Intersection of Two Linked Lists
题目: Write a program to find the node at which the intersection of two singly linked lists begins. ...
- github jekyll site不再使用Maruku由于Markdown翻译员,但kramdown
今天写了一篇博客,之push至jekyll site on github在,发现总是错的,例如,下面的电子邮件消息: The page build completed successfully, bu ...
- Eamcs ditaa基于字符图形产生的图像上
ditta和artist mode这是一个好兄弟.artist mode帮我创建一个字符模式速度,ditta是java计划,字符图形可被读取,并生成图像. ditta网站:http://ditaa.s ...
- ExtJs--02--MessageBox相关弹出窗口alert,prompt,confirm采用
/* Ext.onReady(function(){ Ext.MessageBox.alert("jack","tom"); Ext.MessageBox.al ...
- hdu 4912 Paths on the tree(树链拆分+贪婪)
题目链接:hdu 4912 Paths on the tree 题目大意:给定一棵树,和若干个通道.要求尽量选出多的通道,而且两两通道不想交. 解题思路:用树链剖分求LCA,然后依据通道两端节点的LC ...
- 容易centos配置docker维修
首先.由于docker实施需要linux某些组件支持本身和内核特性.所以一定要确保centos版本号大于6,和内核版本号大于2.6.32-431.可轻松升级centos6到最新的版本号. sudo y ...
- HDU 3032 Nim or not Nim? (需求的游戏SG功能)
意甲冠军:经典Nim游戏转换,给你n礧pi,每个堆栈有pi石头, Alice和Bob轮流石头,意一堆中拿走随意个石子,也能够将某一堆石子分成两个小堆 (每堆石子个数必须不能为0).先拿完者获胜 思路: ...