UILocalNotification *notification=[[UILocalNotification alloc] init]; if (notification!=nil) {//判断系统是否支持本地通知 notification.fireDate = [NSDate dateWithTimeIntervalSince1970:16*60*60*24];//本次开启立即执行的周期 no
1.新建single view工程,导入MediaPlayer库,导入一个视频文件test1.mp4 2.ViewController.h #import <UIKit/UIKit.h> #import <MediaPlayer/MediaPlayer.h> @interface ViewController : UIViewController { MPMoviePlayerViewContro
效果图: 1.实现原理 将所有按钮放在viewcontroller的_buttonArray集合中,同时赋值给按钮中 增加长按手势的响应 当手势坐标进入其他按钮的frame时,调整集合中按钮位置; 当长按手势开始,放大按钮; 结束时还原按钮 2.附源码及注释[ 按钮调控已实现动画 ] @interface UIDragButton : UIButton { CGPoint _prePoin
点击 UITapGestureRecognizer 长按 UILongPressGestureRecognizer 轻扫 UISwipeGestureRecognizer 拖拽 UIPanGestureRecognizer 旋转 UIRotationGestureRecognizer 捏合缩放 UIPinchGestureRecognizer 详细代码如下: #import "ViewContro
案例要求:网络加载图片,随机加载到设置好的视图上 实现的效果图如下: 具体代码如下: // // ViewController.m // 0603---NSOperationQueue #import "ViewController.h" @interface ViewController () @property (nonatomic,strong) NSMutableArray * ima
问题描述:通过picker设置时间,到了设定好的时间 闹钟响起,并弹出提示框,点击确定,停止播放音频。如果设置好了闹钟,没有停在该页面,而是返回了手机主屏幕或是手机锁屏,当到了闹钟设定的时间,会弹出消息通知。(如果设定的时间是已经过去的时间,页面不会有响应,直到设置正确的时间为止.) 效果图如下: 具体代码如下: NaoZhongViewController.m文件 #import "NaoZho
使用sqlite可以实现简单的收藏夹功能,不多说直接上代码。 1.首先导入libsqlite3.0.dylib,libz.dylib两个类库 2.封装一个NSObject类型的类去管理 (即写sql语句) 在这个类里首先导入一个头文件和你建好的model类 (实现收藏本质是存model类) model类只是建立需要的字符串(我只写了.h .m里什么都没写) #import <Foundation/
[super viewDidLoad]; // 获取App的Sandbox路径 NSString *sandboxPath = NSHomeDirectory(); NSLog(@"%@",sandboxPath); //获取Documents路径 NSString *doc = [sandboxPath stringByAppendingPathComponent:@"Documents"];
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField { UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(done:)]; tapGestureRe
-(BOOL)silenced { #if TARGET_IPHONE_SIMULATOR // return NO in simulator. Code causes crashes for some reason. return NO; #endif CFStringRef state; UInt32 propertySize = sizeof(CFStringRef); AudioSessi
一、同步下载(交互不好,容易出现卡死现象,一般下载数据较小或有特定需求才使用)。 发送同步请求后,程序将停止用户交互,直到服务器返回数据完成后,才进行下一步的操作。 步骤: 1.创建NSURL NSURL *url = [[NSURL alloc] initWithString:@"http://www.baidu.com/"]; 2.通过URL创建NSURLRequest NSURLReque
//判断是否有中文 -(BOOL)IsChinese:(NSString *)str { for(int i=0; i< [str length];i++){ int a = [str characterAtIndex:i]; if( a > 0x4e00 && a < 0x9fff) { return YES; } } return NO; } 用法 if ([self PanDuan:@"aa
- (void)applicationDidEnterBackground:(UIApplication *)application{ [[UIApplication sharedApplication] setApplicationIconBadgeNumber:5]; }
经常遇到要给tableView设置背景图片的问题,但如果直接设置背景 backgroundView的话,背景图不会显示,原因是 tableView上的cell默认是不透明的颜色,所以解决方法是 让 cell透明即可: 1.给tableView设置背景view UIImageView *backImageView=[[UIImageViewalloc]initWithFrame:self.vi
这次分享一些数据类型还有时间类型的各种转换方法,有详细注释,话不多说,直接上代码 /** * 时间转换部分 * //从1970年开始到现在经过了多少秒 -(NSString *)getTimeSp { NSString *time; NSDate *fromdate=[NSDate date]; time = [NSString stringWithFormat:@"%f",[fromdate t
//注册键盘出现的通知 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWasShown:) name:UIKeyboardWillShowNotification object:nil]; //注册键盘消失的通知 [[NSNotificationCenter defaultCent
音量振动条 效果图: 如果实现? 创建3个layer,按顺序播放y轴缩放动画 利用CAReplicatorLayer实现 1、什么是CAReplicatorLayer? 一种可以复制自己子层的layer,并且复制出来的layer和原生子层有同样的属性,位置,形变,动画。 2、CAReplicatorLayer属性 instanceCount : 子层总数(包括原生子层) instanceDelay
建立一个单例: DataBaseHandle.h #import <Foundation/Foundation.h> @class PersonModel; @class FMDatabase; @interface DataBaseHandle : NSObject @property(nonatomic,retain)FMDatabase *db; //创建单例的的接口 + (DataBase
//1、调用 自带mail [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto://admin@CodeSnippet.cn"]]; //2、调用 电话phone [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:/
NSString* imageURL = [NSString stringWithFormat: @"http://theimageurl.com/?id=%@", [[resultsEntries objectAtIndex:0] objectForKey: @"image_large"]]; NSData* imageData = [[NSData alloc]initWithContents