汉语字典
来源:互联网 发布:淘宝网2017女装羽绒服 编辑:程序博客网 时间:2024/06/02 11:56
项目三:汉语字典
总结:
一:开机画面的加载进度条
在AppDelegate的
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
中铺一张和LaunchScreen一样的ImageView,然后让进度条做动画。
进度条下面的数字变化,使用计时器,是它改变label.text的值。
关键代码:
[NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(changeAction:) userInfo:nil repeats:YES];
-(void)changeAction:(NSTimer *)sender{ time += 0.05; if (time <= 1.05) { NSString *string = [NSString stringWithFormat:@"%.0f",time*100]; label.text = [string stringByAppendingString:@"%"]; } NSString *string = [NSString stringWithFormat:@"%.0f",time*100]; if ([string isEqualToString:@"125"]) { [sender invalidate]; imageView.hidden = YES ; }}
二、最近搜索
要数据持久化,搜索的数据放在tmp目录下的文件中
关键代码:
//tmp NSString *tmp = NSTemporaryDirectory(); NSString *path = [tmp stringByAppendingPathComponent:@"RecentlySearch"]; NSFileManager *manager = [[NSFileManager alloc]init]; if (![manager fileExistsAtPath:path]) { [manager createDirectoryAtPath:path withIntermediateDirectories:YES attributes:nil error:nil]; } else {// NSLog(@"存在"); }
三、部首检索和拼音检索
这个页面是一个UITableView,里面的用可变数组dataSource装的数据是从SQLITE数据库中读取的。
数据读取方法参考: AlphabelModel.m文件中的+(NSArray*)find;方法。
四、朗读功能
//导入头文件,#import <AVFoundation/AVFoundation.h>
调用系统API 。此处应开辟一个子线程然后在调用朗读的方法,否则若让它在主线程中执行,则会卡UI 。
- (IBAction)soundAction:(UIButton *)sender { NSBlockOperation *blockOperation = [NSBlockOperation blockOperationWithBlock:^{ [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:Nil]; AVSpeechSynthesizer *syner = [[AVSpeechSynthesizer alloc] init]; AVSpeechUtterance *utter = [[AVSpeechUtterance alloc] initWithString:self.simpLabel.text]; float rate = AVSpeechUtteranceMinimumSpeechRate; [utter setRate:rate]; [utter setVoice:[AVSpeechSynthesisVoice voiceWithLanguage:[AVSpeechSynthesisVoice currentLanguageCode]]]; [syner speakUtterance:utter]; }]; [queue addOperation:blockOperation];}
XIB如下:
五、汉字详细介绍页面
1、复制功能:复制当前页面的米字格内的汉字
主要代码:
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];pasteboard.string = self.titleString ;
2.收藏功能:
把当前的页面的字、拼音、部首、笔画写入tmp目录下的文档中,进行数据持久化。
3.分享功能:
分享功能有四中分享,分别是微博、QQ、QQ空间、微信分享
使用COCOPOD导入微博、QQ、微信的第三方
//微信 pod ‘libWeChatSDK’, ‘~> 1.5’ //腾讯 pod ‘TencentOpenApiSDK’, ‘~> 2.9.0’ //微博 pod “WeiboSDK”
在AppDelegate.m文件中
//导入头文件:#import <WeiboSDK.h>#import <TencentOpenAPI/TencentOAuth.h>#import <WXApi.h>
关键代码:
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {// [WeiboSDK enableDebugMode:YES]; [WeiboSDK registerApp:kAppKey]; // TencentOAuth *_tencentOAuth = [[TencentOAuth alloc]initWithAppId:Tencent_AppID andDelegate:nil];// [WXApi registerApp:WX_AppID]; return YES;}-(BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation{ return [TencentOAuth HandleOpenURL:url]; return [WeiboSDK handleOpenURL:url delegate:nil]; return [WXApi handleOpenURL:url delegate:self];}-(BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url{ return [TencentOAuth HandleOpenURL:url]; return [WeiboSDK handleOpenURL:url delegate:nil]; return [WXApi handleOpenURL:url delegate:self];}//微信-(void) onReq:(BaseReq*)req{ if([req isKindOfClass:[GetMessageFromWXReq class]]) { // 微信请求App提供内容, 需要app提供内容后使用sendRsp返回 NSString *strTitle = [NSString stringWithFormat:@"微信请求App提供内容"]; NSString *strMsg = @"微信请求App提供内容,App要调用sendResp:GetMessageFromWXResp返回给微信"; UIAlertView *alert = [[UIAlertView alloc] initWithTitle:strTitle message:strMsg delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil]; alert.tag = 1000; [alert show];// [alert release]; } else if([req isKindOfClass:[ShowMessageFromWXReq class]]) { ShowMessageFromWXReq* temp = (ShowMessageFromWXReq*)req; WXMediaMessage *msg = temp.message; //显示微信传过来的内容 WXAppExtendObject *obj = msg.mediaObject; NSString *strTitle = [NSString stringWithFormat:@"微信请求App显示内容"]; NSString *strMsg = [NSString stringWithFormat:@"标题:%@ \n内容:%@ \n附带信息:%@ \n缩略图:%lu bytes\n\n", msg.title, msg.description, obj.extInfo, msg.thumbData.length]; UIAlertView *alert = [[UIAlertView alloc] initWithTitle:strTitle message:strMsg delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil]; [alert show];// [alert release]; } else if([req isKindOfClass:[LaunchFromWXReq class]]) { //从微信启动App NSString *strTitle = [NSString stringWithFormat:@"从微信启动"]; NSString *strMsg = @"这是从微信启动的消息"; UIAlertView *alert = [[UIAlertView alloc] initWithTitle:strTitle message:strMsg delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil]; [alert show];// [alert release]; }}//微信-(void) onResp:(BaseResp*)resp{ if([resp isKindOfClass:[SendMessageToWXResp class]]) { NSString *strTitle = [NSString stringWithFormat:@"发送媒体消息结果"]; NSString *strMsg = [NSString stringWithFormat:@"errcode:%d", resp.errCode]; UIAlertView *alert = [[UIAlertView alloc] initWithTitle:strTitle message:strMsg delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil]; [alert show];// [alert release]; }}
微博分享
//微博分享 WBMessageObject *message = [WBMessageObject message]; WBImageObject *wbImageObject = [WBImageObject object]; wbImageObject.imageData = [NSData dataWithContentsOfFile:shareFilePath]; message.imageObject = wbImageObject ; WBSendMessageToWeiboRequest *request = [WBSendMessageToWeiboRequest requestWithMessage:message]; [WeiboSDK sendRequest:request];
qq分享
//qq分享//开发者分享图片数据 NSData *imgData = [NSData dataWithContentsOfFile:shareFilePath]; // QQApiImageObject *imgObj = [QQApiImageObject objectWithData:imgData previewImageData:imgData title:@"学霸汉语词典" description:nil]; SendMessageToQQReq *req = [SendMessageToQQReq reqWithContent:imgObj]; //将内容分享到qq [QQApiInterface sendReq:req];
qq空间分享
//qq空间分享//开发者分享图片数据 NSData *imgData = [NSData dataWithContentsOfFile:shareFilePath]; // QQApiImageObject *imgObj = [QQApiImageObject objectWithData:imgData previewImageData:imgData title:@" 学霸汉语词典 " description:nil]; SendMessageToQQReq *req = [SendMessageToQQReq reqWithContent:imgObj]; //将内容分享到qq [QQApiInterface sendReq:req];
微信分享
//微信分享// NSLog(@"weixinShare"); //微信朋友圈分享 WXMediaMessage *message = [WXMediaMessage message]; WXImageObject *wxImageObject = [WXImageObject object]; wxImageObject.imageData = [NSData dataWithContentsOfFile:shareFilePath]; message.mediaObject = wxImageObject ; SendMessageToWXReq *sendMessageToWXReq = [[SendMessageToWXReq alloc]init]; sendMessageToWXReq.scene = 1; sendMessageToWXReq.bText = NO ; sendMessageToWXReq.message = message ; [WXApi sendReq:sendMessageToWXReq];
XIB如下:
七、毛玻璃的使用
//毛玻璃的使用FXBlurView *fxblurView = [[FXBlurView alloc]initWithFrame:CGRectMake(0,0, Screen_Width, Screen_Height)]; fxblurView.dynamic = NO; fxblurView.blurRadius = 40; fxblurView.tintColor = [UIColor clearColor]; [self.view addSubview:fxblurView];
八、获取当前页面的截图
UIGraphicsBeginImageContext(self.view.bounds.size); //currentView 当前的view 创建一个基于位图的图形上下文并指定大小为 [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];//renderInContext呈现接受者及其子范围到指定的上下文 viewImage = UIGraphicsGetImageFromCurrentImageContext();//返回一个基于当前图形上下文的图片 UIGraphicsEndImageContext();//移除栈顶的基于当前位图的图形上下文 UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);//然后将该图片保存到图片图 NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES); NSString *filePath = [[paths objectAtIndex:0] stringByAppendingPathComponent:[NSString stringWithFormat:@"sms.gif"]]; // 保存文件的名称 BOOL result = [UIImagePNGRepresentation(viewImage)writeToFile: filePath atomically:YES]; // 保存成功会返回YES
九、第三方的导入
使用cocoPod导入
platform :ios, '7.0'pod "AFNetworking", "~> 2.5"pod 'SDWebImage'pod 'MJRefresh'pod 'FMDB'pod "WeiboSDK", :git => "https://github.com/sinaweibosdk/weibo_ios_sdk.git"pod 'FXBlurView','~>1.6.3'pod 'libWeChatSDK', '~> 1.5'pod 'TencentOpenApiSDK', '~> 2.9.0'
0 0
- 汉语字典
- 汉语字典
- 汉语字典
- 汉语字典技术文档
- 项目-汉语字典总结
- 汉语字典项目总结
- 汉语字典项目总结
- 汉语字典APP开发总结
- 中国汉语成语字典 v1.25 免费
- 汉语
- 计算所汉语词法分析系统ICTCLAS 字典格式解析
- 计算所汉语词法分析系统ICTCLAS 字典格式解析
- 计算所汉语词法分析系统ICTCLAS 字典格式解析(字典格式说明)
- 汉语编程
- 汉语新难词英译
- 汉语编程
- 汉语排序
- 汉语分词
- 设定三原色的值, 生成对应的屏幕背景
- Python迭代器和生成器
- Android学习第四天之AbsoluteLayout绝对布局
- android去掉 radio 或 checkBox 的默认图标,用自己的图标
- 链式栈
- 汉语字典
- quartz_jobs.xml配置文件样例2--CronTrigger
- 九度OJ 1030:毕业bg (01背包、DP)
- C#中的 int? int??是什么意思
- iOS8以后第三方键盘,获取高度为0的问题
- 67Add Binary
- Mvc Html.BeginForm 方式提交Form前验证
- POJ 2159
- linux文件的隐藏属性chattr,lsattr