Fork me on GitHub
上一页 1 ··· 70 71 72 73 74 75 76 77 78 ··· 125 下一页

2012年3月6日

摘要: 前言初学objectice-C的朋友都有一个困惑,总觉得对objective-C的内存管理机制琢磨不透,程序经常内存泄漏或莫名其妙的崩溃。我在这里总结了自己对objective-C内存管理机制的研究成果和经验,写了这么一个由浅入深的教程。希望对大家有所帮助,也欢迎大家一起探讨。此文涉及的内存管理是针对于继承于NSObject的Class。一 基本原理Objective-C的内存管理机制与.Net/Java那种全自动的垃圾回收机制是不同的,它本质上还是C语言中的手动管理方式,只不过稍微加了一些自动方法。1 Objective-C的对象生成于堆之上,生成之后,需要一个指针来指向它。ClassA * 阅读全文
posted @ 2012-03-06 15:14 pengyingh 阅读(269) 评论(0) 推荐(0)
摘要: 需要创建一个UIView, 把touch event写在此UIView里, 然后在controller里创建此UIView@interface YourCustomView : UIView@implementation YourCustomView// Override this function to get the touch- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ NSLog(@"TOUCH!");}@interface YourViewController : UIViewC 阅读全文
posted @ 2012-03-06 15:06 pengyingh 阅读(523) 评论(0) 推荐(0)
摘要: - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; CGPoint locationInView = [touch locationInView:self]; CGPoint locationInSuperview = [touch locationInView:self.superview]; self.layer.anchorPoint = CGPointMake(locationInView.x / self... 阅读全文
posted @ 2012-03-06 15:01 pengyingh 阅读(406) 评论(0) 推荐(0)
摘要: 转自:http://www.cocoadev.com/index.pl?DoublyLinkedListThe following is the actual Objective C class that implements a doubly-linked list (a variation ofLinkedList). It can do the following:Addition of new elements to the front of the listForward traversal using internal iteratorBackward traversalRemov 阅读全文
posted @ 2012-03-06 14:58 pengyingh 阅读(237) 评论(0) 推荐(0)
摘要: - 自带颜色[selfsetBackgroundColor:[UIColorlightGrayColor]];- 自己设定颜色// R: 128 G: 90 B: 200UIColor*myColor = [UIColorcolorWithRed:(128.0/255.0)green:(90.0/255.0)blue:(200.0/255.0)alpha:1];- 自己设定背景图self.view.backgroundColor= [[UIColoralloc]initWithPatternImage:[UIImageimageNamed:@"whiteBackground.png& 阅读全文
posted @ 2012-03-06 14:57 pengyingh 阅读(118) 评论(0) 推荐(0)
摘要: 如果你是 Objective-C / Cocoa Touch 的重度使用者,那么你一定被一个东西困扰过:不同的 View Controller 之间,如果互相进行沟通?举个常见的例子。假设我们手头上有一个 UIViewController 实例,名叫 parentViewController ,在这个 parentViewController 生命周期的某个节点,它需要以 modal view controller 的形式 present 一个 UIViewController 实例。这个将要被 present 的 UIViewController 实例名叫 childViewControll 阅读全文
posted @ 2012-03-06 14:56 pengyingh 阅读(1404) 评论(0) 推荐(0)
摘要: 转自:http://www.codeios.com/thread-894-1-1.html这个很有用的 UIImage 扩展之前的帖子:UIImage得一个Category, Resizes(调整尺寸),支持放大和旋转,可在许多 App 中使用。代码:// // UIImage-Extensions.h // // Created by Hardy Macia on 7/1/09. // Copyright 2009 Catamount Software. All rights reserved. // #import <Foundation/Foun... 阅读全文
posted @ 2012-03-06 14:43 pengyingh 阅读(349) 评论(0) 推荐(0)
摘要: 在UIImage上加个1像素宽的透明边框UIImage*image = [UIImageimageNamed:@"cardBackDown.png"];CGRectimageRect =CGRectMake(0,0, image.size.width, image.size.height);UIGraphicsBeginImageContext(imageRect.size);[imagedrawInRect:CGRectMake(1,1,image.size.width-2,image.size.height-2)];image =UIGraphicsGetImageFr 阅读全文
posted @ 2012-03-06 14:43 pengyingh 阅读(596) 评论(0) 推荐(0)
摘要: 前一阵子读到一篇介绍CALayer(这里简单地称其为层)的教程,比较简单易懂,适合初学者,我在这里就不完全翻译了,只是把要点说明一下。请注意,我创建的UILable始终随着UIView的根CALayer的缩放而改变位置。)其次,CALayer的可以影响其外观的特性有:层的大小尺寸背景色内容(比如图像或是使用Core Graphics绘制的内容)是否使用圆角是否使用阴影等等需要说明的是CALayer的大部分属性都可以用来实现动画效果。另外,你可以直接使用CALayer,也可以使用其子类,如CAGradientLayer,CATextLayer, CAShapeLayer等等。首先要说的是CALa 阅读全文
posted @ 2012-03-06 14:30 pengyingh 阅读(401) 评论(0) 推荐(0)
摘要: 在tabBar区域加个视图CGRect frame = CGRectMake(0,0,320,48); UIView *v = [[UIView alloc]initWithFrame:frame]; [v setBackgroundColor:[[UIColor allor]initWithRed:70.0/255.0 green:65.0/255.0 blue:62.0/255.0 alpha:1.0]]; [rootController.tabBar insertSubview:v atIndex:0]; [v release];注意:addSubview是将view添加到... 阅读全文
posted @ 2012-03-06 13:37 pengyingh 阅读(4580) 评论(0) 推荐(0)
上一页 1 ··· 70 71 72 73 74 75 76 77 78 ··· 125 下一页

导航