获取一个DeviceId
摘要:-(NSString*)getDeviceId{ NSString* uuidString = nil; if (![[NSUserDefaults standardUserDefaults] objectForKey:@"deviceId"]) { CFUUIDRef uuidRef = CFUUIDCreate(kCFAllocatorDefault); CFStringRef strRef = CFUUIDCreateString(kCFAllocatorDefault, uuidRef); uuidStrin...
阅读全文
自定义一个类似uialertView的view
摘要:在软件开发中,我们有时要很特别的UIalertView,我知道的有两种方式去实现,这里要介绍的就是第二种,在网上看到的,自己整理了一下,源工程的svn地址是:httbydialog.googlecode.com/svn/trunk/,你可以在终端输入:“svn export httbydialog.googlecode.com/svn/trunk/”将他们导出来,一般会自动的存放在home文件夹下(也就是桌面的上一层)。第一种,修改系统的那个东西。 在uialertView的一个delegate方法“- (void)willPresentAlertView:(UIAlertView *)al.
阅读全文
一个关于IAP整理(部份)
摘要:CIapProcess.h#import <Foundation/Foundation.h>#import <StoreKit/StoreKit.h>@protocol IapProcessDelegate <NSObject>-(void)iapProcessBegin;-(void)iapProcessEndWithError:(NSString*)errorString;-(void)showProductByArray:(NSArray*)profuctArray;-(void)transactionSuccess:(SKPaymentTransac
阅读全文
自己定义了个一类似UISegment的东西
摘要:在最近的项目中,总发现给UISegment贴图时有不想要的效果出现,自己就写了一个简单的view,冒充一哈Senment,欢迎补充方法哈CSegmentView.h#import <UIKit/UIKit.h>@interface CSegmentView : UIView{ id target; SEL action;}@property(nonatomic,retain)NSMutableArray* itemArray;@property(nonatomic,assign)int selectIndex;@property(nona...
阅读全文
UITextView和UITextField统计字符和响应Return键
摘要:统计字符:1、UITextView- (void)textViewDidChange:(UITextView *)textView{ int count = [textView.text length]; //这里的count就是字符个数了}2、UITextField方法一:自己先为UITextField的EditingChanged事件添加一个响应方法-(IBAction)valuechange//m_TextField是UITextField的一个IBOutlet{ int count = [m_TextField.text length]; //count就是...
阅读全文
关于xocde4安装cocos2d后 couldn't add 'com.apple.XcodeGenerated' tag to '/Users…
摘要:今天到了新公司,装了xcode4.0.2,随便建了一个工程,总会有十多个错误导致编译失败:错误如下:error: unable to create '/Users/[用户名]/Library/Developer/Xcode/DerivedData/gfhfgh-edhpobgjmxjmsmgimuzpzwmrvgaq/Build/Intermediates' (Permission denied)…Unable to create directory /Users/moqi/Library/Developer/Xcode/DerivedData/gfhfgh-edhpobgjm
阅读全文
(转)一些可能用得到的代码
摘要:转自:http://fei263.blog.163.com/blog/static/927937242009526112420548/- (NSString *)URLEncodedString:(NSString *)string{ NSString *result = (NSStrin*)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault,(CFStringRef)string,NULL,CFSTR("!*'();:@&=+$,/?%#[]"),kCFStringEncodingUTF8
阅读全文
- (UIImage *)stretchableImageWithLeftCapWidth:(NSInteger)leftCapWidth topCapHeight:(NSInteger)topCapHeight图解
摘要:先引用一段: http://www.cnblogs.com/haipingwu/- (UIImage *)stretchableImageWithLeftCapWidth:(NSInteger)leftCapWidth topCapHeight:(NSInteger)topCapHeight这个函数是UIImage的一个实例函数,它的功能是创建一个内容可拉伸,而边角不拉伸的图片,需要两个参数,第一个是不拉伸区域和左边框的宽度,第二个参数是不拉伸区域和上边框的宽度。第一次用这个函数的时候一直搞不懂为什么只要两个参数就行,至少应该指定左上角和右下角,总共四个参数啊。后来读读文档才明白,只需要两个参
阅读全文
UIView圆角
摘要:在实际的应用中,总感觉圆角的东西比较好看,像button,label,image等等,以前的时候我就经常给那些控件添加一个UIImageView作为背景,再搞张圆角的图片,不过今天发现了新方法看代码viewT.layer.cornerRadius = 10;//设置那个圆角的有多圆viewT.layer.borderWidth = 10;//设置边框的宽度,当然可以不要viewT.layer.borderColor = [[UIColor redColor] CGColor];//设置边框的颜色viewT.layer.masksToBounds = YES;//设为NO去试试其实的viewT是
阅读全文
iphone多语言
摘要:转自:http://hi.baidu.com/myguru/blog/category/iphone%20%BF%AA%B7%A2一、获取系统所支持的国际化信息在国际化之前,你可以在iphone中的”设置->通用->多语言环境->语言”中来查看你的iphone支持哪些语言, 当然也可以写一段代码测试一下你的iphone都支持 哪些语言.测试代码如下:NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSArray *languages = [defaults objectForKey:@&quo
阅读全文
kvo/kvc做了简单的介绍(转)
摘要:转自:http://www.cnblogs.com/scorpiozj/archive/2011/03/14/1983643.html对kvo/kvc做了简单的介绍,可作为入门读物。有些术语描述不够精确请指正。欢迎讨论。Kvo是Cocoa的一个重要机制,他提供了观察某一属性变化的方法,极大的简化了代码。这种观察-被观察模型适用于这样的情况,比方说根据A(数 据类)的某个属性值变化,B(view类)中的某个属性做出相应变化。对于推崇MVC的cocoa而言,kvo应用的地方非常广泛。(这样的机制听起来类 似Notification,但是notification是需要一个发送notification
阅读全文
利用时间戳来准确计算某个时间点具现在的时间差(转)
摘要:转自:http://www.cnblogs.com/zhulin/archive/2011/03/28/1997481.html- (NSString *)intervalSinceNow: (NSString *) theDate { NSDateFormatter *date=[[NSDateFormatter alloc] init]; [date setDateFormat:@"yyyy-MM-dd HH:mm:ss"]; NSDate *d=[date dateFromString:theDate]; NSTimeInterval late=[d timeInte
阅读全文
MKMapView上长按屏幕,添加大头针
摘要:在做地图有关的程序时,我们经常需要用户在地图上指定位置我们再用大头针标记。1、在viewDidLoad中添加我们要捕获的手势:UILongPressGestureRecognizer *lpress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPress:)];lpress.minimumPressDuration = 0.5;//按0.5秒响应longPress方法lpress.allowableMovement = 10.0;[m_mapView addGestureRec
阅读全文
UIImage转为灰度图
摘要:转自:http://bj007.blog.51cto.com/1701577/541525-(UIImage*)getGrayImage:(UIImage*)sourceImage { int width = sourceImage.size.width; int height = sourceImage.size.height; CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceGray(); CGContextRef context = CGBitmapContextCreate (nil,width,height,8,0,color
阅读全文
小用NSNotification
摘要:个人觉得用这个东西在不同的viewcontroller间传东西很方便的发消息 [[NSNotificationCenter defaultCenter] postNotificationName:@"popView"/*消息名字,在添加监听时会用到*/ object:@"ShowHomeLineViewController"/*传的参数,多个参数就可以用数组啦*/];收消息1、添加监听: [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(Show:)/*收到
阅读全文