- 博客(33)
- 资源 (3)
- 收藏
- 关注
原创 让控件显示边框
#import view对象.layer.borderColor = UIColor.grayColor.CGColor;view对象.layer.borderWidth = 5;
2011-09-30 14:02:47 788
转载 如何获取iPhone电池的状态和当前的电量
- (void)batteryMoniter { UIDevice *device = [UIDevice currentDevice]; device.batteryMonitoringEnabled = YES; if (device.batteryS
2011-09-29 15:52:59 8321
转载 实现自适应高度的 UITableViewCell 或 UILabel
在iphone开发中处理table时常常会有这样的问题,table中cell的高度不是固定的,而是是根据其中的内容不同而不同的。对与这种情况,sdk本身并没有很好的支持,经过一翻摸索,发现大家通常的做法都是在实现 heightForRowAtIndexPath 方法时,根据内容计
2011-09-29 15:51:54 1227
原创 调用邮件接口发送邮件 调用短信接口发送短信
邮件接口调用: if ([MFMailComposeViewController canSendMail]) { MFMailComposeViewController *mailViewController = [[MFMailComposeViewC
2011-09-29 15:50:17 7654
原创 通过UIWebView 显示图片 文本 pdf 文档 以及音乐和视频
UIWebView *_webView; NSURL *url = [NSURL fileURLWithPath:path]; NSURLRequest *req = [NSURLRequest requestWithURL:url];
2011-09-29 15:47:12 4616
原创 获得文件的属性
NSFileCreationDate = "2011-09-28 05:21:10 +0000"; NSFileExtensionHidden = 0; NSFileGroupOwnerAccountID = 20; NSFileGroupOwnerAcc
2011-09-29 15:28:55 2293
原创 官方将文件size转换为MGB字符串
//功能:将字节大小(Kb)转换为Gb或Mb//参数:KbSizestr: 以Kb为单位的size字符串//返回值:转换为Gb或Mb的字符串NSString * formattedFileSize(unsigned long long size){ NS
2011-09-29 15:21:56 1107
原创 得到iPhone用户的首选语言
NSUserDefaults* defs = [NSUserDefaults standardUserDefautls];//得到用户缺省值NSArray* languages = [defs objectForKey:@"AppleLanguages"];//在缺省
2011-09-29 15:00:15 1705
原创 提示框 选择对话框 等待框
等待框:UIAlertView *showWaitingAlert(){ UIAlertView *waittingAlert = [[UIAlertView alloc] initWithTitle: @"正在获取数据" message: @"
2011-09-29 10:03:01 3785
原创 view 重绘
当绘图绘制在view上,可以调用[view setNeedsDisplay];系统会回调drawRect方法,当view上小范围重复刷新,建议使用[view setNeedsDisplayInRect:];设置绘制区域如果绘制layer上,同样可以调用[layer set
2011-09-28 17:02:20 911
原创 截屏 或 截取某个view的界面(给view拍照)
基本原理就是主要将UIView的layer描绘到图形上下文。UIView全局拍照和局域拍照的代码如下:1 UIView全局拍照- (UIImage *) screenImage:(UIView *)view {UIImage *screenImage;UIGrap
2011-09-28 16:50:01 1593
原创 跑马灯效果
CGRect frame = labelShow.frame; frame.origin.x = -180; labelShow.frame = frame; [UIView beginAnimations:@"testAnimation
2011-09-28 15:11:47 488
原创 iPhone开发中视频播放与通告(Notification)
以下是一个非常简单的视频播放代码,并且可以简单的理解Cocoa中的通告使用方法。- (void)playMovieAtURL:(NSURL*)theURL //简单的方法,传入一个视频地址{MPMoviePlayerController *thePlayer = [[
2011-09-27 17:17:22 714
原创 UIImageView iPhone中用手势实现图片操作
UIImage * image=[UIImage imageNamed:@"php.gif"];[imageView setImage:image];因为种种原因,需要在iphone应用中实现图片查看功能,由于iphone屏幕支持多点触摸,于是是想到用“手势”来实现图片的
2011-09-27 15:25:22 2662
原创 UIAccelerometer 加速计
UIAccelerometer加速计是用来检测iphone手机在x.y.z轴三个轴上的加速度。要获得此类调用:UIAccelerometer *accelerometer = [UIAccelerometer sharedAccelerometer];同时,你需要设置它的
2011-09-27 15:14:20 598
原创 用摄像头画面做 view 背景的代码例子
This action starts camera as a backgroud of the view:--(IBAction)btnStartCamera_TouchUpInside{picker = [[UIImagePickerController alloc
2011-09-27 15:13:27 763
原创 通过URL调用系统的其他程序 如: 短信 电话 ipod ipod播放列表 ipod的视频。。。
在iPhone中,可以直接用UIApp打开URL地址。如下所示:[ UIApp openURL: [ NSURL URLWithString:@"http://www.apple.com" ] ];或者:[ UIApp openURL: [ NSURL URLWith
2011-09-27 14:56:29 757
转载 iphone 开发中属性 property 和 synthesize 权威的介绍
在Objective-c 2 .0中引入了 property 和 synthesize 为方便存取 1 让大家认识一下 property and synthesize 吧 @property预编译命令的作用是自动声明属性的setter和getter方法 @sy
2011-09-27 14:54:07 828
翻译 iOS 4中禁止程序退出后保留在后台的方法
只需要在plist中加入UIApplicationExitsOnSuspend。Opting Out of Background ExecutionIf you do not want your application to remain in the backgroun
2011-09-27 14:52:29 758
原创 如何让Cocoa程序支持多语言本地化处理
大部分情况下,在屏幕上显示除了英文之外的特定语言,通过[statusItem setTitle:@“停止"];进行显示,并不是一个好办法,因为你可能希望进行更多其他语言的支持。至少OS X中内建了多语言支持,而且用程序支持这种机制也并不复杂。仔细阅读本文,你会掌握如何用C
2011-09-27 14:50:09 1615
原创 NSString NSMutableString字符串 用一个字符替换其中的某个字符 字符串
NSString ::::: NSString *time = [[timeString stringByReplacingOccurrencesOfString:@"T" withString:@" "] substringToIndex:19];NSMutable
2011-09-20 11:39:30 19592
原创 NSDictionary 读写 plist 文件
第一种: // 写到plist文件中 [dic writeToFile:testPath atomically:YES]; //读取到一个NSDictionary NSDictionary *dictionary = [[NSDict
2011-09-16 13:05:49 15687
原创 iPhone-获取网络数据或者路径的文件名以及后缀
// 从路径中获得完整的文件名(带后缀) exestr = [filePath lastPathComponent]; NSLog(@"%@",exestr);// 获得文件名(不带后缀)exestr = [exestr stringByDeletingPat
2011-09-15 12:41:26 8040
原创 Public UTIs supported by Mac OS X v10.3
Technical Q&A QA1406Public UTIs supported by Mac OS X v10.3Q: What are the public UTIs supported by Mac OS X v10.3?A: What are the pub
2011-09-14 14:57:38 790
原创 防止程序进入休眠状态
设置应用程序的 idleTimerDisabled 属性为 YES (默认为NO)[UIApplication sharedApplication].idleTimerDisabled=YES;//当然一定要慎用,记着退出程序时把自动休眠功能开启
2011-09-14 14:07:38 3936
转载 iPhone网络软件防止机子进入睡眠(断线)
iPhone网络软件在睡眠情况断线是本文要介绍的内容,如果你希望使用iPhone的网络功能并保持长连接,并使用Wifi的话,你可能会发现一个问题,那就是在iPhone处于睡眠状态时,Wifi会中断,这样程序就无法保持连接。(iPhone非官方SDK)下面的代码可能会帮你解决这
2011-09-08 17:13:41 1289
原创 Code Sign error: Provisioning profile ‘XXXX’ can't be found
在Xcode中当你在更新了你得证书而再重新编译你的程序,真机调试一直会出现 Code Sign error: Provisioning profile ‘XXXX’ can't be found是不是会另你很恼火。下面说说解决方法,让你很好的解决这个问题。
2011-09-07 17:09:52 2314
原创 将图片缩放成指定大小(压缩方法)
- (UIImage *)scaleToSize:(UIImage *)img size:(CGSize)size{ // 创建一个bitmap的context // 并把它设置成为当前正在使用的context UIGraphicsBeginI
2011-09-06 10:35:55 10490
转载 iPhone UIImage保存到文件,PNG/JPEG自适应
+ (BOOL)writeImage:(UIImage*)image toFileAtPath:(NSString*)aPath{ if ((image == nil) || (aPath == nil) || ([aPath isEqualToStrin
2011-09-06 00:21:11 1638
转载 如何旋转rotate UIImage
+(UIImage *)rotateImage:(UIImage *)aImage{ CGImageRef imgRef = aImage.CGImage; CGFloat width = CGImageGetWidth(imgRef)
2011-09-06 00:20:00 3036
转载 根据UIImage创建任意大小thumbnail
+ (UIImage*)thumbnailOfImage:(UIImage*)image withSize:(CGSize)aSize{ //NSLog(@"create thumbnail image"); if
2011-09-06 00:17:41 1531
原创 UILabel 自动换行 和支持换行符
NSString *str = @"你要放在label里的文本字符串 \n 换行符";CGSize size = [str sizeWithFont:[UIFont systemFontOfSize:14] constrainedToSize:CGSizeMake(width,10000.0f)lineBreakMode:UILineBreakModeWordWrap];UILabel
2011-09-02 17:18:17 84637 4
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人