摘要:
库中添加AVFoundation.framework#import<AVFoundation/AVFoundation.h>@interface tanzoe_ViewController :UIViewController<AVAudioPlayerDelegate>//添加协议<AVAudioPlayerDelegate>{AVAudioPlayer *mp3;//定义对象}NSString *questionSoundName = @"pao_bg";NSString *currentSoundFilePath = [[NSBund 阅读全文
摘要:
[UIView commitAnimations]; [UIViewbeginAnimations:nil context:nil]; [UIViewsetAnimationRepeatAutoreverses:YES];//动画是否返回 [UIViewsetAnimationDuration:0.3]; button.alpha=0; [UIViewcommitAnimations];CATransition的type属性1.#define定义的常量kCATransitionFade交叉淡化过渡kCATransitionMoveIn新视图移到旧视图上面kCATransitionPu... 阅读全文
摘要:
NSArray:有序的集合,存储的元素在一个整块的内存中并按序排列(废话,我学过c语言的数组这还不知道啊);NSSet:无序的集合,散列存储。读developer.apple关于NSSet的解释:You can use sets as an alternative to arrays when the order of elements isn’t important and performance in testing whether an object is contained in the set is a consideration—while arrays are ordered, 阅读全文
摘要:
可以用字符串来找方法SEL 变量名 = NSSelectorFromString(方法名字的字符串);//注意 变量名 不是指针 可以运行中用SEL变量反向查出方法名字字符串NSString *变量名 = NSStringFromSelector(SEL参数); 阅读全文
摘要:
label.transform = CGAffineTransformMakeRotation(90 *M_PI / 180.0);//顺时针旋转 90度label.transform = CGAffineTransformMakeRotation(180 *M_PI / 180.0);//顺时针旋转180度label.transform = CGAffineTransformMakeRotation(270 *M_PI / 180.0);//顺时针旋转270度CGAffineTransform transform = label.transform;transform = CGAffineT 阅读全文
摘要:
UIAlertView * baseAlert; baseAlert =[[[UIAlertView alloc]initWithTitle:@"please wait" message:nildelegate:self cancelButtonTitle:nil otherButtonTitles:nil]autorelease];//定义[baseAlert show];UIActivityIndicatorView *aiv = [[UIActivityIndicatorViewalloc]initWithActivityIndicatorStyle:UIActivi 阅读全文
摘要:
[[UIApplication sharedApplication] setStatusBarHidden:YES];隐藏状态栏[UIApplication sharedApplication].applicationIconBadgeNumber =5; 给应用程序贴标记[[UIApplication sharedApplication] setIdleTimerDisabled:YES]; 不让程序待机使用网络活动指示器(即状态栏菊花转动)UIApplication *app = [UIApplication sharedApplication]; app.networkActivityI 阅读全文
摘要:
release一个对象后立即把指针清空 (release一个空指针完全是合法的,不会发生任何事情)[object release];object = nil;指针赋值给另一个指针NSMutableArray *array = [[NSMutableArray alloc]init];NSLog(@"%d",[array retainCount]);//count is 1NSMutableArray *temp = array;[temp retain];NSLog(@"%d,%d",[array retaincount],[temp retaincou 阅读全文
摘要:
- (void)viewDidLoad{[super viewDidLoad];UIImage * image = [UIImage imageNamed:@"alien.png"];CGSize size = image.size;UIImageView *imgview = [[UIImageView alloc]initWithFrame:(CGRect){{100,100},size}];imgview.image = image; [self.view addSubview:imgview];imgview.userInteractionEnabled = YES 阅读全文
摘要:
代码: //选择按钮NSArray*buttonNames = [NSArray arrayWithObjects:@"今天", @"本周", @"本月",nil]; UISegmentedControl * segmentedControl = [[UISegmentedControl alloc]initWithItems:buttonNames];[segmentedControl setFrame:CGRectMake(60, 10, 200, 40)]; segmentedControl.selectedSegmentInd 阅读全文
摘要:
loadView: (加载视图) - 建立层次结构 - 在不使用 Interface Builder 的时候发生viewDidLoad: (视图已加载) - 加载附加的资源和数据viewWillAppear: (视图快要被显示) - 准备在屏幕上加载 - 视图不会在每次显示重新加载viewDidAppear: (视图已被显示) - 动画和其他视觉元素被加载执行优先顺序从上往下 阅读全文
摘要:
分别给出BOOL,int,float,指针变量 与“零值”比较的 if 语句(假设变量名为var)解答: BOOL型变量:if(!var)int型变量: if(var==0)float型变量: const float EPSINON = 0.00001;if ((x >= - EPSINON) && (x <= EPSINON)指针变量: if(var==NULL)剖析: 考查对0值判断的“内功”,BOOL型变量的0判断完全可以写成if(var==0),而int型变量也可以写成if(!var),指针变量的判断也可以写成if(!var), 上述写法虽然程序都能正确运行 阅读全文
摘要:
if 语句与布尔值if 语句是 C++/C 语言中最简单、最常用的语句,然而很多程序员用隐含错误的方式 写 if 语句。假设布尔变量名字为 flag,它与零值比较的标准 if 语句如下:if (flag) // 表示 flag 为真if (!flag) // 表示 flag 为假其它的用法都属于不良风格,例如: if (flag == TRUE)if (flag == 1 )if (flag == FALSE)if (flag == 0) 阅读全文
摘要:
获取当前的系统时间 年-月-日 小时-分钟-秒代码如下:NSDate * newDate = [NSDate date];//实例化一个NSDateFormatter对象NSDateFormatter*dateformat=[[NSDateFormatter alloc]init];//设定时间格式,这里可以设置成自己需要的格式[dateformatsetDateFormat:@"yyyy-MM-dd HH:mm:ss"];NSString *newDateOne = [dateformatstringFromDate:newDate];[dateformatsetForm 阅读全文
摘要:
线程(thread):用于指代独立运行的代码段进程(process):用于指代正在运行的可执行程序,它可以包含多个线程RunLoop 接受输入事件来自两种不同的来源:输入源(inputsource)和 定时源(timer source)输入源 传递异步事件,通常消息来自于其它线程和程序。定时源 则传递同步事件,发生在特定时间或者重复的时 阅读全文
摘要:
定义:pageControl = [[[UIPageControl alloc]initWithFrame:CGRectMake(300, 200, 100, 30)]autorelease];//定义初始化 [pageControl setNumberOfPages:9];//设置总页数 [pageControl setCurrentPage:0];//设置当前页[pageControl addTarget:self action:@selector(clickpagecontrol) forControlEvents:UIControlEventValueChanged];//添加事件 [ 阅读全文
摘要:
UIImage *image = [UIImage imageNamed:filename]; CGImageRef imageRef = image.CGImage; CGRect rect = CGRectMake(origin.x, origin.y ,size.width, size.height); CGImageRef imageRefRect = CGImageCreateWithImageInRect(imageRef, rect); UIImage *imageRect = [[UIImage alloc] initWithCGImage:imageR... 阅读全文
摘要:
1. NSSearchPathForDirectoriesInDomains和NSHomeDirectory iPhone和symbian 3rd一样,会为每一个应用程序生成一个私有目录,这个目录位于/Users/sundfsun2009/Library/Application Support/iPhone Simulator/User/Applications下,并随即生成一个数字字母串作为目录名,在每一次应用程序启动时,这个字母数字串都是不同于上一次。 通常使用Documents目录进行数据持久化的保存,而这个Documents目录可以通过 NSSearchPa... 阅读全文
摘要:
addSubview和insertSubview的区别?addSubview 是将view加到所有层的最顶层相当于将insertSubview的atIndex参数设置成view.subviews count即[view addSubview:oneview] == [view insertSubview:oneview atIndex:view.subviews count]addSubview是加到最后insertSubview是加到指定的位置insert可以在你指定inde 阅读全文
摘要:
一、添加 Quartz Core 框架要使用 Quartz Core 框架,你需要将其添加到你的工程中 。 然后 #import <Quartz Core/QuartzCore.h> 二、认识图层对 ps 有所了解的人都知道图层的概念,在这里也一样。在PS中一张图片至少得有一个图层,一个或多个图层的叠加构成了一张位图。我们这里一个或多个图层的叠加的构成了UIView(或其派生类)对象。看过我关于 UIView 文章的人可能会有疑问:UIView 和图层没啥区别啊?NO,还是有区别的,图层是有弹性的,你可以操纵图层,使 UIView 有各种效果,比如三维效果,形变等等。要访问一个图层 阅读全文