版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、获取系统语言设置NSUserDefaults*userDefault=[NSUserDefaultsstandardUserDefaults];NSArray*languages=[userDefaultobjectForKey:@"AppleLanguages"];NSString*preferredLang=[languagesobjectAtIndex:0];2、缓存路径下文件大小-(unsignedlonglongint)cacheFolderSize{NSFileManager*_manager=[NSFileManagerdefaultManager];NSArray*_cachePaths=NSSearchPathForDirectoriesInDomains(NSCachesDirectory,
NSUserDomainMask,YES);NSString*_cacheDirectory=[_cachePathsobjectAtIndex:];NSArray*_cacheFileList;NSEnumerator*_cacheEnumerator;NSString*_cacheFilePath;unsignedlonglongint_cacheFolderSize=;_cacheFileList=[_managersubpathsAtPath:_cacheDirectory];_cacheEnumerator=[_cacheFileListobjectEnumerator];while(_cacheFilePath=[_cacheEnumeratornextObject]){NSDictionary*_cacheFileAttributes=[_managerfileAttributesAtPath:[_cacheDirectorystringByAppendingPathComponent:_cacheFilePath]traverseLink:YES];_cacheFolderSize+=[_cacheFileAttributesfileSize];}//单位是字节return_cacheFolderSize;}3、Popoverpush时Frame无法改变解决办法在popover中的ViewController中实现:-(void)viewWillAppear:(BOOL)animated
{CGSizesize=CGSizeMake(320,480);//sizeofviewinpopoverself.contentSizeForViewInPopover=size;[superviewWillAppear:animated];}4、tableview滑动导致NSTimer和委托回调停止解决办法//请求回调NSURLRequest*请求=...scheduleInRunLoop:[NSRunLoopcurrentRunLoop]
forMode:NSRunLoopCommonModes]
[连接开始]//定时器回调NSTimer*updateTimer=[NSTimerscheduledTimerWithTimeInterval:0.01f目标:自我选择:选择(updatePencent)的UserInfo:无重复:是];*NSRunLoop主要=[NSRunLoopcurrentRunLoop]
[主要addTimer:updateTimerforMode:NSRunLoopCommonModes];5、手势识别类UIGestureRecognizer6、SFHFKeychainUtils存储信息苹果SDK自带的就有密码保护,使用方法很简单,如下:1、引入Security.frameWork框架。2、引入头文件:SFHKeychainUtils.h.3、存密码:[SFHFKeychainUtilsstoreUsername:@"dd"andPassword:@"aa"forServiceName:SERVICE_NAMEupdateExisting:1error:nil];[SFHFKeychainUtilsdeleteItemForUsername:@"dd"andServiceName:SERVICE_NAMEerror:nil];4、取密码:NSString*passWord=[SFHFKeychainUtilsgetPasswordForUsername:@"dd"andServiceName:SERVICE_NAMEerror:nil];7、missingrequiredarchitecturei386infile解决办法在TargetInfo里面修改FrameworkSearchPasths删除里面内容就可以了。8、view放大缩小动画效果//创建缩小了的视图
myWeiBoImageVC=[[UIViewControlleralloc]init];
myWeiBoImageVC.view.clipsToBounds=YES;
myWeiBoImageVC.view.alpha=0.0;
myWeiBoImageVC.view.frame=CGRectMake(64,0,1024-64,768-20);
[self.viewaddSubview:myWeiBoImageVC.view];
CGAffineTransformnewTransform=
CGAffineTransformScale(myWeiBoImageVC.view.transform,0.1,0.1);
[myWeiBoImageVC.viewsetTransform:newTransform];
myWeiBoImageVC.view.center=CGPointMake(670,100);
[selfperformSelector:@selector(imageViewControllerBigAnimation)];
//放大刚刚创建缩小后的视图
-(void)imageViewControllerBigAnimation{
[UIViewbeginAnimations:@"imageViewBig"context:nil];
[UIViewsetAnimationDuration:0.5];
CGAffineTransformnewTransform=CGAffineTransformConcat(myWeiBoImageVC.view.transform,CGAffineTransformInvert(myWeiBoImageVC.view.transform));
[myWeiBoImageVC.viewsetTransform:newTransform];
myWeiBoImageVC.view.alpha=1.0;
myWeiBoImageVC.view.center=CGPointMake(416,510);
[UIViewcommitAnimations];
}
//缩小视图隐藏
-(void)imageViewControllerSmallAnimation{
[UIViewbeginAnimations:@"imageViewSmall"context:nil];
[UIViewsetAnimationDuration:0.5];
CGAffineTransformnewTransform=CGAffineTransformScale(myWeiBoImageVC.view.transform,0.1,0.1);
[myWeiBoImageVC.viewsetTransform:newTransform];
myWeiBoImageVC.view.center=CGPointMake(670,100);
[UIViewcommitAnimations];
}9、UIScrollView控制View缩放allImageScrollView=[[UIScrollViewalloc]initWithFrame:CGRectMake(0,0,768,1024)];
allImageScrollView.minimumZoomScale=0.3;
allImageScrollView.maximumZoomScale=1.0;
allImageScrollView.backgroundColor=[UIColorclearColor];
allImageScrollView.delegate=self;
[self.viewaddSubview:allImageScrollView];
mPicStatusesViewController=[[PicStatusesViewControlleralloc]init];
[allImageScrollViewaddSubview:mPicStatusesViewController.view];
//UIScrollViewDelegete实现
-(UIView*)viewForZoomingInScrollView:(UIScrollView*)scrollView{
returnmPicStatusesViewController.view;//返回ScrollView上添加的需要缩放的视图
}
-(void)scrollViewDidZoom:(UIScrollView*)scrollView{
//缩放操作中被调用
}
-(void)scrollViewDidEndZooming:(UIScrollView*)scrollViewwithView:(UIView*)viewatScale:(float)scale{
//缩放结束后被调用
}10、iOS3.2播放视频NSString*urlString=[NSStringstringWithString:@"视频url"];NSURL*movieUrl=[[NSURLalloc]initWithString:urlString];
MPMoviePlayerController*myMoviePlayer=[[MPMoviePlayerControlleralloc]initWithContentURL:movieUrl];
myMoviePlayer.view.frame=CGRectMake(250,250,350,350);
[self.viewaddSubview:myMoviePlayer.view];
myMoviePlayer.shouldAutoplay=YES;
myMoviePlayer.scalingMode=MPMovieScalingModeAspectFit;
[myMoviePlayerplay];11、谷歌地图翻起动画效果CATransition*animation=[CATransitionanimation];
[animationsetDelegate:self];
[animationsetDuration:0.35];
[animationsetTimingFunction:UIViewAnimationCurveEaseInOut];
if(!curled){animation.type=@"pageCurl";
animation.fillMode=kCAFillModeForwards;
animation.endProgress=0.40;
}else{
animation.type=@"pageUnCurl";
animation.fillMode=kCAFillModeBackwards;
animation.startProgress=0.30;
}
[animationsetRemovedOnCompletion:NO];
[self.viewexchangeSubviewAtIndex:0withSubviewAtIndex:1];
[self.view.layeraddAnimation:animationforKey:@"pageCurlAnimation"];12、给View添加阴影和边框UIImageView*imgvPhoto=[UIImageViewalloc]init];
//添加边框
CALayer*layer=[_imgvPhotolayer];
layer.borderColor=[[UIColorwhiteColor]CGColor];
layer.borderWidth=5.0f;
//添加四个边阴影
_imgvPhoto.layer.shadowColor=[UIColorblackColor].CGColor;
_imgvPhoto.layer.shadowOffset=CGSizeMake(0,0);
_imgvPhoto.layer.shadowOpacity=0.5;
_imgvPhoto.layer.shadowRadius=10.0;
//添加两个边阴影
_imgvPhoto.layer.shadowColor=[UIColorblackColor].CGColor;
_imgvPhoto.layer.shadowOffset=CGSizeMake(4,4);
_imgvPhoto.layer.shadowOpacity=0.5;
_imgvPhoto.layer.shadowRadius=2.0;13、使用NSTimer与UIView动画实现飘雪效果viewDidLoad事件中,增加一个图片及定时器并启动,这里的pic请在头文件中定义。-(void)viewDidLoad{
[superviewDidLoad];
self.pic=[UIImageimageNamed:@"snow.png"];//初始化图片
//启动定时器,实现飘雪效果
[NSTimerscheduledTimerWithTimeInterval:(0.2)target:selfselector:@selector(ontime)userInfo:nilrepeats:YES];
}然后再实现定时器定时调用的ontime方法:
-(void)ontime{
UIImageView*view=[[UIImageViewalloc]initWithImage:pic];//声明一个UIImageView对象,用来添加图片
view.alpha=0.5;//设置该view的alpha为0.5,半透明的
intx=round(random()20);//随机得到该图片的x坐标
inty=round(random()20);//这个是该图片移动的最后坐标x轴的
ints=round(random())+10;//这个是定义雪花图片的大小
intsp=1/round(random()0)+1;//这个是速度
view.frame=CGRectMake(x,-50,s,s);//雪花开始的大小和位置
[self.viewaddSubview:view];//添加该view
[UIViewbeginAnimations:nilcontext:view];//开始动画
[UIViewsetAnimationDuration:10*sp];//设定速度
view.frame=CGRectMake(y,500,s,s);//设定该雪花最后的消失坐标
[UIViewsetAnimationDelegate:self];
[UIViewcommitAnimations];
}14、配置Xcode看程序崩溃信息1、在xcode中的左侧目录中找到Executables打开2、双击和工程名一样的文件。3、在打开的文件中的Arguments选项,在下面的框中加入Name:NSZombieEnabled设置value为YES。15、程序中发送邮件和检测设备邮箱是否被配置-(void)addEmail{ClassmailClass=(NSClassFromString(@"MFMailComposeViewController"));if(mailClass!=nil){if([mailClasscanSendMail]){[selfdisplayComposerSheet];}else{[selflaunchMailAppOnDevice];}}else{[selflaunchMailAppOnDevice];}}-(void)displayComposerSheet{MFMailComposeViewController*controller=[[MFMailComposeViewControlleralloc]init];controller.navigationBar.tag=1002;[self.navigationController.navigationBarsetNeedsDisplay];controller.mailComposeDelegate=self;[controllersetSubject:@"意见反馈"];[controllersetToRecipients:[[NSArrayalloc]initWithObjects:@"555@",nil]];NSString*emailBody=nil;[controllersetMessageBody:emailBodyisHTML:YES];[selfpresentModalViewController:controlleranimated:YES];[controllerrelease];}#pragmamarkmailComposeDelegate(void)mailComposeController:(MFMailComposeViewController*)controllerdidFinishWithResult:(MFMailComposeResult)resulterror:(NSError*)error{if(result==MFMailComposeResultSent){[selfdismissModalViewControllerAnimated:YES];}if(result==MFMailComposeResultSaved){[selfdismissModalViewControllerAnimated:YES];}if(result==MFMailComposeResultFailed){Emailalert=[[UIAlertViewalloc]initWithTitle:@""message:@"发送失败"delegate:se
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年租赁赔偿金合同
- 2026年高考数学立体几何考点解析试卷
- 档案管理应急制度
- 山东省昌乐县第一中学2026年高考模拟考试(第四次统测)化学试题含解析
- 山东专卷博雅闻道2026届高三下学期第二次质量检测试题化学试题试卷含解析
- 福建省建瓯市二中2026年高三第二次质量检测试题生物试题含解析
- 云南省永仁县一中2026年第二学期高三年级生物试题期中考试试卷含解析
- 2026年下学期六年级语文学习共同体评价
- 车间安全作业培训
- 车间二级培训
- 2026贵州贵阳市安航机械制造有限公司招聘8人考试重点试题及答案解析
- 2026年空天科技卫星互联网应用报告及未来五至十年全球通信创新报告
- (正式版)DB51∕T 3342-2025 《炉灶用合成液体燃料经营管理规范》
- 2025年上海市普通高中学业水平等级性考试地理试卷(含答案)
- 腔镜器械的清洗与管理
- 江南大学《食品科学与工程》考研真题及答案解析
- 眼科:青光眼患者药物治疗指南
- 2025年计算机等级考试(NCRE)一级人工智能与大模型基础样题及参考答案
- 2025年汉语桥的考试题目及答案
- 医护服务意识培训
- 芬兰烟熏桑拿体验创新创业项目商业计划书
评论
0/150
提交评论