iOS零碎小知识

iOS零碎小知识,第1张

概述使应用不会自动锁屏。 [UIApplication sharedApplication].idleTimerDisabled=YES;//不自动锁屏[UIApplication sharedApplication].idleTimerDisabled=NO;//自动锁屏 程序图标不加高光效果 iOS程序build到手机上时,默认的桌面图标是有高亮的光圈效果的。如果您要去掉这一高亮特效,可以在程序 使应用不会自动锁屏。
[UIApplication sharedApplication].IDleTimerDisabled=YES;//不自动锁屏[UIApplication sharedApplication].IDleTimerDisabled=NO;//自动锁屏

程序图标不加高光效果
iOS程序build到手机上时,默认的桌面图标是有高亮的光圈效果的。如果您要去掉这一高亮特效,可以在程序的 info.pList 设置Icon already includes gloss effects,值设定为YES,默认值是NO。程序上传到App Store 也就不会在图标上添加高亮特效了。

判断屏幕分辨率
BOol retina = CGSizeEqualToSize(CGSizeMake(640,960),[[UIScreen mainScreen] currentMode].size);
返回true说明当前分辨率是CGSizeMake(640,960),false则不是

遇到类似这样的错误Failed to get the task for process XXX
多半是证书问题,project和targets证书都要是可用并且正确的证书才行。

出现这样的问题Property's synthesized getter follows Cocoa naming convention for returning 
Property's synthesized getter follows Cocoa naming convention for returning.
今天早上在整理代码的时候发现了如上警告。
在网上查询后发现,是因为苹果在新的编码,不推荐变量以new、copy等关键字开头。
突然想起来之前也有朋友问过类似的问题。特做以记录。
也希望大家在以后编码的时候,能够多多注意。

快速获取沙盒路径
#define documentS_FolDER [NSHomeDirectory() stringByAppendingPathComponent:@
"documents"]

判断邮箱是否合法
- (BOol) valIDateEmail: (Nsstring *) candIDate {Nsstring *emailRegex = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+.[A-Za-z]{2,4}"; nspredicate *emailTest = [nspredicate predicateWithFormat:@"SELF MATCHES %@",emailRegex]; return [emailTest evaluateWithObject:candIDate];}
显示网络活动状态 
UIApplication* app = [UIApplication sharedApplication];app.networkActivityIndicatorVisible = YES; // to stop it,set this to NO


显示一组连续的图片(类似动画效果)
NSArray *myImages = [NSArray arrayWithObjects:    [UIImage imagenamed:@"myImage1.png"],[UIImage imagenamed:@"myImage2.png"],[UIImage imagenamed:@"myImage3.png"],[UIImage imagenamed:@"myImage4.gif"],nil];UIImageVIEw *myAnimatedVIEw = [UIImageVIEw alloc];[myAnimatedVIEw initWithFrame:[self bounds]];myAnimatedVIEw.animationImages = myImages;myAnimatedVIEw.animationDuration = 0.25; // secondsmyAnimatedVIEw.animationRepeatCount = 0; // 0 = loops forever[myAnimatedVIEw startAnimating];[self addSubvIEw:myAnimatedVIEw];[myAnimatedVIEw release];


页面切换效果设置
controller.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentModalVIEwController:controller animated:YES];


可供使用的效果:
UIModalTransitionStyleCoverVertical
UIModalTransitionStyleFlipHorizontal
UIModalTransitionStyleCrossdissolve
UIModalTransitionStylePartialCurl


恢复之前的页面:
[self dismissModalVIEwControllerAnimated:YES];

为UIImageVIEw添加单击事件:
imageVIEw.userInteractionEnabled = YES;UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(yourHandlingCode:)];[imageVIEw addGestureRecognizer:singleTap];

获取应用版本

NSDictionary* infoDict =[[NSBundle mainBundle] infoDictionary];Nsstring* versionNum =[infoDict objectForKey:@"CFBundLeversion"];Nsstring*appname =[infoDict objectForKey:@"CFBundledisplayname"];
总结

以上是内存溢出为你收集整理的iOS零碎小知识全部内容,希望文章能够帮你解决iOS零碎小知识所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1053821.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-25
下一篇 2022-05-25

发表评论

登录后才能评论

评论列表(0条)

保存