iOS一些常用的小知识点
//获取全局的Delegate对象,这样我们可以调用这个对象里的方法和变量
[[UIApplication sharedApplication] delegate];
//获得程序的主Bundle
NSBundle *bundle = [NSBundle mainBundle];
/*
在程序中播放声音
1.添加AudioToolbox框架
*/
NSString *path = [bundle pathForResource:@"soundFileName" ofType:@"wav"];
SystemSoundID soundId;
AudioServicesCreateSystemSoundID((__bridge CFURLRef)([NSURL URLWithString:path]), &soundId);
AudioServicesPlayAlertSound(soundId);
//捕捉程序关闭或者进入后台事件
UIApplication *application = [UIApplication sharedApplication];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillResignActive:) name:UIApplicationWillResignActiveNotification object:application];
}
- (void)applicationWillResignActive:(NSNotification *)noti{
}
#pragma mark -- 获取截屏
- (UIImage *)getScreenShot{
UIGraphicsBeginImageContext(self.view.bounds.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
最新文章
- 对copy、mutableCopy理解
- mybatis的mapper中,实体非空检验问题
- Net操作Excel(终极方法NPOI)
- qt-5.6.0 移植之qt文件系统的建立
- 编写高质量代码--改善python程序的建议(六)
- PHP中该怎样防止SQL注入?
- 3行3列表格 table实现,div+css实现
- MySQL用命令行复制表的方法
- c# datagridviewcomboboxcell值无效的解决办法
- html-----vedio标签(HTML5新标签VIDEO在IOS上默认全屏播放)
- 关于div+css排版布局中需注意的细节问题
- 使用swiper简单的h5下滑翻页效果,
- 二分查找、two points、排序
- php foreach
- js call 和 apply方法记录
- Centos6.6下编译安装Apache2.2.31
- php与redis使用经验分享 (转载)
- 8 -- 深入使用Spring -- 7...3 让Spring管理控制器
- java中调用groovy
- sqlserver字符串多行合并为一行