摘要: 一、assign属性 当数据类型为int、float等原生类型时,可以使用assign,否则可能导致内存泄露。例如当使用malloc分配了一块内存,并把它的地址赋值给了指针a,后来如果希望指针b也共享这块内存,于是讲a赋值给(assgin)b。这时就用到了assgin,此时a和b指向同一块内存。但是现在问题出现了,当a不再需要这块内存时,能都直接释放呢?肯定是不能的,因为a并不知道b是否还在使用这块内存,如果a释放了,那么b在使用这块内存的时候引起程序crash掉。二、retain属性 retain属性就是为了解决上述问题而提出的,使用了引用计数(reference counting),还.. 阅读全文
posted @ 2012-07-05 06:54 FoxBabe 阅读(5758) 评论(0) 推荐(0) 编辑
摘要: 目录树的主要部分有root(/)、/usr、/var、/home等等。下面是一个典型的linux目录结构如下: / 根目录 /bin 存放必要的命令 /boot 存放内核以及启动所需的文件等 /dev 存放设备文件 /etc 存放系统的配置文件 /home 用户文件的主目录,用户数据存放在其主目录中 /lib 存放必要的运行库 /mnt 存放临时的映射文件系统,我们常把软驱和光驱挂装在这里的floppy和cdrom子目录下。 /proc 存放存储进程和系统信息 /root 超级用户的主目录 /sbin 存放系统管理程序 /tmp 存放临时文件的目录 /usr 包含了一般不需要修改的应用程序,命 阅读全文
posted @ 2012-05-27 08:47 FoxBabe 阅读(1844) 评论(1) 推荐(0) 编辑
摘要: //通过点击事件自动轮换隐藏和显示导航栏- (void)clickimage:(id)sender{ BOOL navBarState = [self.navigationController isNavigationBarHidden];//获取当前的导航栏是否隐藏 [self.navigationController setNavigationBarHidden:!navBarState animated:YES]; [self.navigationController setToolbarHidden:!navBarState animated:YES]; if ... 阅读全文
posted @ 2012-05-13 15:32 FoxBabe 阅读(775) 评论(0) 推荐(1) 编辑
摘要: 在现在的ios sdk中,我们一般通过UIApplication的setStatusBarOrientation:来进行View的强制旋转(当然,还要配合- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation),但是,setStatusBarOrientation并不一定马上会执行shouldAutorotateToInterfaceOrientation进行界面旋转,这时,有个小技巧可以让界面马上旋转过来,那就是调用一下 UINavigationController 阅读全文
posted @ 2012-05-13 15:27 FoxBabe 阅读(348) 评论(0) 推荐(1) 编辑
摘要: #import <Foundation/Foundation.h>@interface Base64Code : NSObject+ (NSString * )encodeBase64:(NSString * )input;//加密+ (NSString * )decodeBase64:(NSString * )input;//解密@end #import "Base64Code.h"#import "GTMBase64.h"@implementation Base64Code//加密+ (NSString * )encodeBase64:( 阅读全文
posted @ 2012-05-13 15:16 FoxBabe 阅读(494) 评论(0) 推荐(1) 编辑
摘要: //// Histogram.h// CGraph//// Created by Fox on 12-4-16.// Copyright 2012 __MyCompanyName__. All rights reserved.////绘制柱状图#import <UIKit/UIKit.h>#define kindex 4@interface Histogram : UIView { CGFloat colors[kindex][4];//每一个柱状图的颜色 CGRect rects[kindex];//每一个柱状图的大小形状 CGContextRef canvas; CGFloat 阅读全文
posted @ 2012-05-13 15:02 FoxBabe 阅读(413) 评论(0) 推荐(1) 编辑
摘要: //// ViewController.m// RunLoopDemo//// Created by Fox on 12-5-13.// Copyright (c) 2012年 __MyCompanyName__. All rights reserved.//#import "ViewController.h"@interface ViewController ()@end@implementation ViewController- (void)viewDidLoad{ [super viewDidLoad]; //使用NSTimer创建定时器 NSTimeInt... 阅读全文
posted @ 2012-05-13 14:49 FoxBabe 阅读(480) 评论(0) 推荐(1) 编辑
摘要: 创建线程有三种方法:一、通过[NSThread detachNewThreadSelector:@selector(addAction) toTarget:self withObject:nil]创建,无具体的返回对象,线程不受用户控制,控制权掌握在系统的手中;二、通过[[NSThread alloc] initWithTarget:self selector:@selector(addNumberTo:) object:maxNumber]创建,通过该方式创建的线程由用户自己管理;三、自定义线程,通过继承NSThread来实现。//// ViewController.m// Thread.. 阅读全文
posted @ 2012-05-13 14:46 FoxBabe 阅读(312) 评论(0) 推荐(1) 编辑
摘要: 方法一:通过View的中心位置来移动-(BOOL)textFieldShouldReturn:(id)sender{ self.view.center=CGPointMake(160,207); [sender resignFirstResponder]; return YES;}- (BOOL)textFieldShouldBeginEditing:(id)sender{ UITextField *textField = (UITextField *)sender; if(textField.tag==1) { self.view.ce... 阅读全文
posted @ 2012-05-08 07:33 FoxBabe 阅读(520) 评论(0) 推荐(1) 编辑
摘要: UIImageView *imageview1 = [[UIImageView alloc] initWithFrame:CGRectMake(125, 50, 229, 229)]; [imageview1 setImage:[UIImage imageWithContentsOfFile:path]]; imageview1.userInteractionEnabled = YES; UITapGestureRecognizer *singleTap1 = [[UITapGestureRecognizer alloc] initWi... 阅读全文
posted @ 2012-05-05 06:45 FoxBabe 阅读(6890) 评论(0) 推荐(1) 编辑
摘要: UIView设置背景图片可以使用如下代码: self.view.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"dula.png"]];但是,这段代码存在一个危险。alloc和init一个对象后,count就会加1,这时需要调用release方法来释放内存。设置UIView背景图片更为保险的方法是:self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@" 阅读全文
posted @ 2012-05-04 23:14 FoxBabe 阅读(332) 评论(1) 推荐(1) 编辑
摘要: iPhone系统的字体数量有限,并且多数对中文没有效果,下面介绍两种解决办法方法1: 添加对应的字体(.ttf或.odf)到工程的resurce,使用cocos2d中的FontLabel库,FontLabel继承于UILabel,象UILabel一样使用就好了 fontName直接使用添加的资源名字即可方法2; 1,添加对应的字体(.ttf或.odf)到工程的resurce,例如simkai.ttf 2,在info.plist中添加一项 Fonts provided by application (item0对应的value为simkai.ttf,添加多个字体依次添加就可以了) 3,... 阅读全文
posted @ 2012-05-04 23:08 FoxBabe 阅读(627) 评论(1) 推荐(1) 编辑
摘要: 将UIView的最初位置置为窗口之外,然后通过一个动画来实现UIView的飞入效果,固定好进入的位置。 [newvision setFrame:CGRectMake(-200,30,175,145)]; [UIView beginAnimations:nil context:nil]; [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; [UIView setAnimationDuration:1]; //动画时长 [newvision setFrame:CGRectMake(5,30,175,14... 阅读全文
posted @ 2012-05-04 08:27 FoxBabe 阅读(558) 评论(0) 推荐(1) 编辑
摘要: 用UIImage加载图像的方法很多,最常用的是下面三种:一、用imageNamed函数引用[UIImage imageNamed:ImageName];二、用NSData的方式加载NSString *filePath = [[NSBundle mainBundle] pathForResource:fileName ofType:extension]; NSData *image = [NSData dataWithContentsOfFile:filePath]; [UIImage imageWithData:image];三,使用[UIImage imageWithContentOfFil 阅读全文
posted @ 2012-05-04 08:20 FoxBabe 阅读(434) 评论(0) 推荐(1) 编辑
摘要: 1、引入头文件#include <sys/sysctl.h>#include <mach/mach.h>2、检测函数//MARK: 可用内存- (double)availableMemory{ vm_statistics_data_t vmStats; mach_msg_type_number_t infoCount = HOST_VM_INFO_COUNT; kern_return_t kernReturn = host_statistics(mach_host_self(),HOST_VM_INFO,(host_info_t)&vmStats,&in 阅读全文
posted @ 2012-05-04 08:15 FoxBabe 阅读(644) 评论(3) 推荐(1) 编辑
摘要: iPhone程序发布的时候应该会用到下面这些图标,大小和用途如下:图片大小(px)文件名用途重要程度512X512iTunesArtworkiTunes商店上展示可以没有,推荐有57X57Icon.pngiPhone/iPod touch上的App Store以及Home界面这个必须要有114X114Icon@2x.pngiPhone 4(高分辨率)的Home 界面可以没有,推荐有72x72Icon-72.png兼容iPad的Home界面可以没有,推荐有29x29Icon-Small.pngSpotlight搜索以及设置界面可以没有,推荐有50x50Icon-Small-50.png兼容iPa 阅读全文
posted @ 2012-05-03 23:54 FoxBabe 阅读(4306) 评论(0) 推荐(1) 编辑
摘要: 一、静态图片的设置iOS设备现在有三种不同的分辨率:iPhone 320x480、iPhone 4 640x960、iPad 768x1024。以前程序的启动画面(图片)只要准备一个 Default.png 就可以了,但是现在变得复杂多了。下面就是 CocoaChina 会员做得总结 如果一个程序,既支持iPhone又支持iPad,那么它需要包含下面几个图片:Default-Portrait.png iPad专用竖向启动画面 768x1024或者768x1004Default-Landscape.png iPad专用横向启动画面 1024x768或者1024x748Default-Portra 阅读全文
posted @ 2012-04-14 02:52 FoxBabe 阅读(5035) 评论(3) 推荐(1) 编辑
摘要: 如果要移除一个 UIView 的所有子视图,SDK 里没有 remove all 之类的方法。可以用 for loop 循环调用 – removeFromSuperview 来移除 例如:for(UIView *view in [self.view subviews]){ [view removefromsuperview];}如果要移动指定的视图,可以这样: for(UIView *mylabelview in [self.view subviews]) { if ([mylabelview isKindOfClass:[UILabel class]]) { ... 阅读全文
posted @ 2012-04-14 02:40 FoxBabe 阅读(11230) 评论(0) 推荐(1) 编辑
摘要: 上下划动可以用类似的方法实现:#import <UIKit/UIKit.h>@interface Abstruct : UIViewController <UIScrollViewDelegate>{ UIImageView* myimageview; NSMutableArray *imgArray; CGPoint FirstPoint; CGPoint SecondPoint; NSInteger Page; BOOL touchMove;}@property (retain, nonatomic) UIImageView* myimageview;... 阅读全文
posted @ 2012-04-13 13:07 FoxBabe 阅读(2958) 评论(0) 推荐(1) 编辑
摘要: MPMoviePlayerViewController用于播放视频,用法如下:NSBundle *bundle = [NSBundle mainBundle];NSString *moviePath = [bundle pathForResource:@"movie" ofType:@"mp4"];NSURL *movieURL = [NSURL fileURLWithPath:moviePath];MPMoviePlayerViewController *moviePlayerViewController = [[MPMoviePlayerViewCo 阅读全文
posted @ 2012-04-13 08:00 FoxBabe 阅读(624) 评论(1) 推荐(1) 编辑