UIWebView 相应本地事件

UIWebView 相应本地事件,第1张

概述Objective-c代码   - (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType {           AppDelegate *appDelegate=(   Ap Objective-c代码 -(BOol)webVIEw:(UIWebVIEw*)webVIEwshouldStartLoaDWithRequest:(NSURLRequest*)requestnavigationType:(UIWebVIEwNavigationType)navigationType{ AppDelegate*appDelegate=( AppDelegate*)[[UIApplicationsharedApplication]delegate]; if(navigationType==UIWebVIEwNavigationTypelinkClicked){ NSURL*URL=[requestURL]; NSLog([URLscheme]); NSLog([URLabsoluteString]); //codehereandcallthedelegatemethod NSautoreleasePool*pool=[[NSautoreleasePoolalloc]init]; BOolaudioResult=FALSE; NSfileManager*fileManager=[NSfileManagerdefaultManager]; //checkiffileexistedincachefolder NSArray*cache=NSSearchPathForDirectorIEsInDomains(NSCachesDirectory,NSUserDomainMask,YES); Nsstring*cachePath=[cacheobjectAtIndex:0]; Nsstring*filepath; filepath=[cachePathstringByAppendingPathComponent:[audioIDstringByAppendingString:@".wav"]]; if([fileManagerfileExistsAtPath:filepath]==YES){ [selfplayVoice:filepath]; } else { audioResult=[appDelegatesaveAudio:audioID]; if(audioResult==YES) //NSLog(@"Speaktheaudiobythepath=%@",filepath); [poolrelease]; [appDelegatesaveAudio:gotFM]; }

保存声音的方法:
-(BOol)saveAudio:(Nsstring*)key NSLog(key); BOolsaveSuccess=FALSE; Nsstring*dbPath=[[[NSBundlemainBundle]resourcePath]stringByAppendingPathComponent:@"testVoice.db"]; if(sqlite3_open([dbPathUTF8String],&database_voice)==sqlITE_OK) Nsstring*sqlString=[NsstringstringWithFormat:@"select*fromtb_voicewhereID='%@'",key]; NSLog(sqlString); constchar*sql_char=[sqlStringUTF8String]; //preparetheselectstatement intreturnValue=sqlite3_prepare_v2(database_voice,sql_char,-1,&selectStatement,NulL); if(returnValue==sqlITE_OK) //loopalltherowsreturnedbythequery. if(sqlite3_step(selectStatement)==sqlITE_ROW) Nsstring*filename=[NsstringstringWithUTF8String:(char*)sqlite3_column_text(selectStatement,0)]; ////NSLog(filename); NSData*fileData=[NSDatadataWithBytes:sqlite3_column_blob(selectStatement,0)">2)length:sqlite3_column_bytes(selectStatement,0)">2)]; //savethefiledata //check Nsstring*filepath=[cachePathstringByAppendingPathComponent:filename]; filepath=[filepathstringByAppendingString:@".wav"]; if([fileManagercreateDirectoryAtPath:cachePathattributes:nil]==NO){ ////NSLog(@"fileManagercreateDirectoryAtPath:cachePathattributes:nil"); if([fileDatawritetofile:filepathatomically:YES]){ saveSuccess=TRUE; //NSLog(@"saveSuccess"); ////NSLog(@"returnValue"); //NSLog(@"saveFail"); sqlite3_finalize(selectStatement); returnsaveSuccess; } 总结

以上是内存溢出为你收集整理的UIWebView 相应本地事件全部内容,希望文章能够帮你解决UIWebView 相应本地事件所遇到的程序开发问题。

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

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

原文地址: http://outofmemory.cn/sjk/1176555.html

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

发表评论

登录后才能评论

评论列表(0条)

保存