
oc学习
文章平均质量分 60
_BinC
IOS开发者
展开
-
iOS中CFUUIDRef,CFUUIDCreate声称唯一字符串
CFUUIDRef theUUID =CFUUIDCreate(NULL); CFStringRef guid = CFUUIDCreateString(NULL, theUUID); CFRelease(theUUID); NSString *uuidString = [((NSString *)guid)stringByReplacingOccurrenc原创 2014-04-04 17:02:47 · 2670 阅读 · 0 评论 -
oc学习之旅:内存管理2修改数组为非ARC版本
为了重写数组的非arc版本,特意添加了一个Person类,把Person添加到自定义的数组类中,因为是强引用,所以添加完后把Person类释放掉,然后再把每个元素释放掉后会打印Person与自定义数组类的dealloc方法,顺序是先是调用Person的dealloc在调用自定义数组类的dealloc。每个功能都要实现内存管理,这样才不导致内存泄露#import #import "P原创 2013-12-25 19:10:24 · 616 阅读 · 0 评论 -
uiview子视图Center中心点2,层层叠加子视图,release与removeFromSuperview区别
/* UIView: 坐标相关属性:frame位置 大小 bounds(以自身为参考坐标 起始点(0,0)) center中心点(相对于父视图而言) UIView只能有一个父视图 可以有多个子视图 */ UIView *v =[[UIViewalloc] initW原创 2013-12-25 17:45:00 · 1393 阅读 · 0 评论 -
UIView操作:插入添加置顶,判断一个视图是否为子视图view
for (int>0;>3; i++) { UIView *v = [[UIViewalloc] initWithFrame:CGRectMake(30*i,30*i+50, 80, 80)]; v.backgroundColor =[[UIColoralloc] initWithRed:arc4random()%256/255.0gr原创 2013-12-25 17:10:36 · 6486 阅读 · 0 评论 -
UIBUTTON添加图片点击-tag一个图片亮其他图片都灭
//给按钮设置图片 [b setImage:[UIImageimageNamed:@"unchecked.png"]forState:UIControlStateNormal]; [b addTarget:selfaction:@selector(click:)forControlEvents:UIControlEventTouchUpInside];原创 2013-12-25 17:08:33 · 725 阅读 · 0 评论 -
UIView视图移动,抖动效果,定时器,动画block
for (int i =0; i2; i++) { UIImageView * img = [[UIImageViewalloc] initWithFrame:CGRectMake(270*i,20+410*i, 50, 50)]; if (i == 0) { img.image = [UIImageimageN原创 2013-12-26 11:57:51 · 1027 阅读 · 0 评论 -
UIView-tag
UIView *v =[[UIViewalloc] initWithFrame:CGRectMake(10,20, 320, 30)]; v.tag =200; v.backgroundColor = [UIColorblackColor]; [self.windowaddSubview:v]; [vrelea原创 2013-12-25 17:50:22 · 703 阅读 · 0 评论 -
UIView-tag循环图片点击图片
//添加初始图片 UIImageView *imgView = [[UIImageViewalloc] initWithFrame:CGRectMake(0,20, 250, 300)]; imgView.center =CGPointMake(160,240); imgView.image = [UIImageimageNamed:@"1.原创 2013-12-26 09:43:19 · 674 阅读 · 0 评论 -
UIView子视图Center中心点
/* UIView: 坐标相关属性:frame(相对父视图而言)位置大小 bounds(以自身为参考坐标起始点(0,0)) center 中心点(相对父视图而言) UIView只能有一个父视图 但可以有多个子视图 */ UIView * v = [[UIViewalloc]原创 2013-12-25 17:31:53 · 1111 阅读 · 0 评论 -
UIBUTTON电话界面
//7.0着色 //父视图着色改变那么上面的所有的子视图着色都会改变 self.window.tintColor = [UIColorredColor]; //7.0无边框按钮 for (int i=0; i7 ;i++) { UIButton *b =[UIButtonbuttonWithType原创 2013-12-24 16:57:39 · 561 阅读 · 0 评论 -
UILabel仿qq对话
NSArray *arr = [[NSArrayalloc] initWithObjects:@"我发现你越来越不爱我了,只爱你的工作!",@"我怎么不爱你了?",@"我明天不吃饭了,去把你经理打一顿!",@"为什么打我经理?",@"呜你果然不爱我了!你都不问我为什么不吃饭..",nil]; CGFloat>20; UILabel * label;原创 2013-12-25 19:37:02 · 733 阅读 · 0 评论 -
停靠模式:子视图自适应父视图长度宽度左边距右边距上下边距
UIView *v = [[UIViewalloc] initWithFrame:CGRectMake(0,20, 200, 200)]; v.tag =100; v.backgroundColor = [UIColororangeColor]; [self.windowaddSubview:v]; [vrelease];原创 2013-12-26 14:40:40 · 752 阅读 · 0 评论 -
oc学习之旅:KVO
#import #import "Bank.h"#import "Person.h"int main(int argc,const char * argv[]){ @autoreleasepool { /* KVC:义字符串替代访问器(getter setter)修改成员变量原创 2013-12-26 19:05:29 · 616 阅读 · 0 评论 -
oc学习之旅:协议 银行转账
协议:TellREcevie.h 与 SendProtocol.hTellREcevie.h-(void)tellRecevie:(NSNumber *)money;SendProtocol.h-(void)sendMoney:(NSNumber *)money;流程,userA转钱给银行,银行转钱给B,B收到钱了通知银行,银行通知A#原创 2013-12-26 18:37:20 · 653 阅读 · 0 评论 -
oc学习之旅:内存管理,文件操作流程
#import #import "Tail.h"#import "Cat.h"#define PATH @"XXXXXXXXXXXXXX"int main(int argc,const char * argv[]){ @autoreleasepool { /* NSFi原创 2013-12-26 17:54:21 · 642 阅读 · 0 评论 -
KVC
#import #import "Person.h"#import "Group.h"int main(int argc,const char * argv[]){ @autoreleasepool { /* KVC:Key Value Coding */ Per原创 2013-12-26 18:58:31 · 561 阅读 · 0 评论 -
oc学习之旅:协议
构造一个士兵代理教官的开火的方法,并返回一个对话,教官有相应的对话,然后让士兵去执行。main#import #import "Master.h"#import "Solider.h"int main(int argc,const char * argv[]){ @autoreleasepool {原创 2013-12-26 17:46:42 · 600 阅读 · 0 评论 -
oc学习之旅:简单协议
#import #import "Boss.h"#import "Coder.h"int main(int argc,const char * argv[]){ @autoreleasepool { /* 协议:本质就是一组接口 协议代理作用在:传参原创 2013-12-26 19:37:04 · 535 阅读 · 0 评论 -
oc学习之旅:数组浅拷贝深拷贝
//copy NSString * str1 = @"wahaha"; NSString * str2 = [str1 copy]; NSString * str3 = [str1 retain]; NSLog(@"str1 %p str2 %p str4 %p",str1,str2,str3);原创 2013-12-26 19:25:29 · 809 阅读 · 0 评论 -
oc学习之旅:自动释放池
#import #import "Person.h"int main(int argc,const char * argv[]){ // NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];早期自动释放池 @autoreleasepool { /*原创 2013-12-26 17:49:26 · 562 阅读 · 0 评论 -
UIView实现星级评定
准备两张五颗星的图片中,有一张是灰色的一张是黄色的星星,效果为点到一定区域就会显示半颗星和一个星变黄。在黄色星星上应该采用clipsToBounds来显示图片达到评分效果。每个星星的位置分为三段,第一段评分上一科星星的分数,第二段评分为半颗星的分数,第三段分为整颗星星的分数。运用逻辑运算来实现该分数。 UIImageView *imgView = [[UIImageViewalloc原创 2013-12-26 17:30:18 · 1029 阅读 · 0 评论 -
UIImageView
/* UIImage 保存图片数据 UIImageView显示图片 */ //读取工程文件中得图片 //某一个张图片会被多次显示时优先使用 UIImage *img = [UIImageimageNamed:@"640*960.png"]; //图片仅仅显示一次又不想占用缓存空间优先原创 2013-12-24 14:29:25 · 502 阅读 · 0 评论 -
UIBUTTON点击事件
#import "Person.h"@implementation AppDelegate- (void)dealloc{ [_arrrelease]; [self.windowrelease]; [superdealloc];}- (BOOL)application:(UIApplication *)applicati原创 2013-12-24 11:57:38 · 1125 阅读 · 0 评论 -
NSDate
//NSData ios中二进制类 NSString *str =@"wahaha"; //字符串转二进制 NSData *data =[strdataUsingEncoding:NSUTF8StringEncoding]; NSLog(@"str : %@ data : %@",str,data);原创 2013-12-18 14:39:42 · 526 阅读 · 0 评论 -
oc学习之旅:NSDictionary
NSArray *arr =@[@"1",@"2",@"3"]; //字典类加方法 NSDictionary *dic =@{@"1":@"one",@"2":@"two",@"3":@"three"}; NSLog(@"arr is %@ dic is %@",arr,dic); //字典键值原创 2013-12-17 14:05:32 · 579 阅读 · 0 评论 -
oc学习之旅:NSArray分割,排序,Block
字符串分割单个分割 NSString * str =@"adadhbdj,dfaslkdsafj,fdsakfasdkf,dddddd,eeeee,1234,2345,"; NSArray * arr = [strcomponentsSeparatedByString:@","]; NSLog(@"%@",arr);原创 2013-12-16 17:20:37 · 1086 阅读 · 0 评论 -
UIBarButton,UINavigationItem,UINavigationBar,UIToolear区别
UINavigationController:管理UIView使用视图控制器 管理视图控制器UINavigationController切换 push… pop…以栈的形式管理UIViewControllerUIViewController切换 presentViewController /dissmiss..UIViewController管理UIView: ctl.view原创 2013-12-30 10:39:19 · 926 阅读 · 0 评论 -
UINavigateController到指定层数,退到指定层数
- (void)viewDidLoad{ [superviewDidLoad];// Do any additional setup after loading the view. self.navigationItem.titleView.frame =CGRectMake(120,0, 80,30); self.title原创 2013-12-30 09:07:48 · 787 阅读 · 0 评论 -
oc学习之旅:NSArray
OC中NSArray保存id类型得数据相当于加方法NSArray *arr = @[@"0",@"1",@"2"];表示数组元素个数arr.countNSArray为静态数组,初始化后不能被修改。NSArray * arr1 = [[NSArray alloc] initWithObjects:@"1",@"2",@"3",nil];NSArray * arr2 = [原创 2013-12-16 13:59:21 · 717 阅读 · 0 评论 -
导航控制器:UINavigationController
/* 导航控制器:UINavigationController继承自UIViewController 视图控制器:UIViewController UINavigationController:管理UIViewController UIViewController:管理UIView UINavigationCont原创 2013-12-29 21:36:43 · 682 阅读 · 0 评论 -
oc学习之旅:NSString2
*****字符串比较bool [str1 isEqualToString:str2],相等返回布尔类型1,不能为0NSString * str1 = @"hello";NSString *str2 = @"hello1"if([str1 isEqualToString:str2]);[str1 compare:str2]与c中比较字符串一致,返回值为(-1)NSOrderedAsc原创 2013-12-12 14:14:59 · 469 阅读 · 0 评论 -
oc学习之旅:NSString3
NSString vs. NSMutableStringNSString在完成实例化后无法被修改 NSMUTableString是NSString的子类,字符串是可变的NSMutableString *str1 = [[NSMutableString alloc] init];追加字符[str1 appendString:@"wahaha"];NSLog(@"%@",str原创 2013-12-12 17:05:46 · 616 阅读 · 0 评论 -
oc学习之旅:文件操作
文件操作#import #define PATH @"/Users/chanbin/Desktop/Class7Test"#define PATH1 @"/Users/chanbin/Desktop/Class7Test/a0.txt"#define PATH2 @"/Users/chanbin/Desktop/"int main(int a原创 2013-12-18 15:51:55 · 586 阅读 · 0 评论 -
oc学习之旅:NSFileHandle与NSFileManager实现FileCopy
#import #define SRCPATH @"/Users/chanbin/Desktop/release.mp4"#define DESPATH @"/Users/chanbin/Desktop/RE.mp4"int main(int argc,const char * argv[]){ @autoreleasepool {原创 2013-12-18 18:56:14 · 785 阅读 · 0 评论 -
UIView显示对话
float curHeight =20; //字体字典修改字典 //ios7.0 NSDictionary *dic; if (SYSTEMVERSION_7) { UIFont *font =[UIFontsystemFontOfSize:17]; dic =[NSDict原创 2013-12-24 10:37:27 · 514 阅读 · 0 评论 -
添加应用程序图文件
120代表5代以上58代表3gs以下80代表4代以下原创 2013-12-24 09:42:13 · 403 阅读 · 0 评论 -
UIView给控件边框加阴影
UIView *v =[[UIViewalloc] initWithFrame:CGRectMake(50,50, 50, 50)]; v.backgroundColor = [UIColorblackColor]; v.layer.shadowOpacity =0.8; v.layer.shadowOffset =CGSizeMake原创 2013-12-24 09:06:04 · 849 阅读 · 0 评论 -
UIBUTTON
UIButton *b =[UIButtonbuttonWithType:UIButtonTypeInfoLight]; b.frame =CGRectMake(50,50, 50, 50); [b addTarget:selfaction:@selector(click)forControlEvents:UIControlEventTouchUpIns原创 2013-12-24 09:24:27 · 414 阅读 · 0 评论 -
oc学习之旅:内存管理
以前的代码都是使用非ARC(手动管理),而ARC还不太完善,因此学习非ARC模式还是有必要的。在用非ARC模式引用计数器概念oc中,在oc定义的类型都设计有一个引用计数器retainCount。而oc中的引用分两种,一种是强引用retain(对应ARC中的strong),另一种是弱引用assign(对应ARC中weak)。原创 2013-12-20 20:40:14 · 880 阅读 · 0 评论 -
UIRefressController下拉刷新 刷新记录上次时间
新建的是继承自uirefreshcontroller类,具体代码如下- (void)viewDidLoad{ [superviewDidLoad]; // Uncomment the following line to preserve selection between presentations. // self.clear原创 2014-01-07 10:39:37 · 760 阅读 · 0 评论