查资料,看到了有关消息的知识,蛮好的
http://www.cnblogs.com/kenshincui/p/4168532.html
6.16
iOS 给字符串加上双引号
使用转义字符 \
NSString * tmp = @"a\"a\"a";
有关视频,音频的
http://www.cnblogs.com/kenshincui/p/4186022.html
6.24
设置button根据文字多行显示
http://code4app.com/requirement/53563970933bf092398b490f
转眼7-17了
07-17
一 。。把HTML文本去掉标签
NSString * content = resultDic[@"content"][0];
NSRegularExpression *regularExpretion=[NSRegularExpressionregularExpressionWithPattern:@"<[^>]*>|\n"
options:0
error:nil];
content=[regularExpretion stringByReplacingMatchesInString:contentoptions:NSMatchingReportProgressrange:NSMakeRange(0, content.length)withTemplate:@"-"];//替换所有html和换行匹配元素为"-"
regularExpretion=[NSRegularExpressionregularExpressionWithPattern:@"-{1,}"options:0error:nil] ;
content=[regularExpretion stringByReplacingMatchesInString:contentoptions:NSMatchingReportProgressrange:NSMakeRange(0, content.length)withTemplate:@"-"];//把多个"-"匹配为一个"-"
label.text = content;二。。 button 根据文字自适应大小
NSString * title =self.siyuanLoc[i];
CGSize titleSize = [titlesizeWithAttributes:@{NSFontAttributeName:[UIFontfontWithName:button.titleLabel.font.fontNamesize:16]}];
titleSize.height =30;
titleSize.width +=20;
button.frame =CGRectMake(CGRectGetMaxX(formerButton.frame) +15, CGRectGetMinY(formerButton.frame), titleSize.width, titleSize.height);
07-21
最近遇到了在block里面操作成员变量和控制器本身的情况,学习到了,这种情况还是蛮多的,要记住
http://www.aslibra.com/blog/read.php/1771.htm
[[UINavigationBar appearance] setBarTintColor:[UIColor purpleColor]];
改变所有 UINavigationBar
07-28
1~~~下载音频视频并保存到相册
NSURLSessionConfiguration *configuration = [NSURLSessionConfigurationdefaultSessionConfiguration];
AFURLSessionManager *manager = [[AFURLSessionManageralloc] initWithSessionConfiguration:configuration];
NSURL *URL = [NSURLURLWithString:self.downloadUrl];
NSURLRequest *request = [NSURLRequestrequestWithURL:URL];
NSURLSessionDownloadTask *downloadTask = [managerdownloadTaskWithRequest:request progress:nildestination:^NSURL *(NSURL *targetPath,NSURLResponse *response) {
NSURL *documentsDirectoryURL = [[NSFileManagerdefaultManager] URLForDirectory:NSDocumentDirectoryinDomain:NSUserDomainMaskappropriateForURL:nilcreate:NOerror:nil];
return [documentsDirectoryURLURLByAppendingPathComponent:[NSStringstringWithFormat:@"mp3Download%@",[responsesuggestedFilename]]];
// NSURL *temporaryDirectoryURL =[NSURL URLWithString:[NSTemporaryDirectory() stringByAppendingString:[NSString stringWithFormat:@"mp4Download%@",[response suggestedFilename]]]];
// return temporaryDirectoryURL;
} completionHandler:^(NSURLResponse *response,NSURL *filePath, NSError *error) {
if (error) {
NSLog(@" error error === %@",error);
}
[[DMCAlertCenterdefaultCenter]postAlertWithMessage:@"音乐下载成功"];
NSLog(@"File downloaded to: %@", filePath);
//视频录制成功后存入相册
// self.enableRotation=YES;
// UIBackgroundTaskIdentifier lastBackgroundTaskIdentifier=self.backgrounsTaskIdentifier;
// self.backgrounsTaskIdentifier=UIBackgroundTaskInvalid;//任务标识设置为UIBackgroundTaskInvalid,标志我们的任务结束。
ALAssetsLibrary *assetsLibrary=[[ALAssetsLibraryalloc]init];
[assetsLibrary writeVideoAtPathToSavedPhotosAlbum:filePathcompletionBlock:^(NSURL *assetURL,NSError *error) {
if (error) {
NSLog(@"保存音乐出错");
}
// if (lastBackgroundTaskIdentifier!=UIBackgroundTaskInvalid) {
// [[UIApplication sharedApplication]endBackgroundTask:lastBackgroundTaskIdentifier];
// }
NSLog(@"成功保存到相册");
//测试播放
// MPMoviePlayerViewController * playerView = [[MPMoviePlayerViewController alloc] initWithContentURL:filePath];
//
// [self presentViewController:playerView animated:YES completion:^{
//
// }];
}];
}];
[downloadTask resume];
2~~~ 使用webView 加载音频链接
需要给webView 添加属性 ,而加载视频则不需要
_webView.allowsInlineMediaPlayback = YES;
_webView.mediaPlaybackRequiresUserAction = NO;