iOS小记

2019-04-15 16:10发布

1.iOS切换使用http :  NSAppTransportSecurity NSAllowsArbitraryLoads 2.图片布局设置
  1. UIImage *pic = [ UIImage imageNamed:@"IMG_0404.PNG"];  
  2. UIImageView *imageView   = [[UIImageView alloc] initWithFrame:CGRectMake(20, 20, 240, 100 )];  
  3. [imageView setImage:pic];  
  4. [imageView setContentScaleFactor:[[UIScreen mainScreen] scale]];  //根据屏幕类别选择图片
  5. imageView.contentMode =  UIViewContentModeScaleAspectFill;  
  6. imageView.autoresizingMask = UIViewAutoresizingFlexibleHeight;  
  7. imageView.clipsToBounds  = YES;
3.svn常用命令 http://www.cnblogs.com/newstar/archive/2011/01/04/svn.html

4,Search Bar 怎样去掉背景的颜 {MOD}(storyboard里只能设置background颜 {MOD},可是发现clear Color无法使用)

其实在代码里还是可以设置的,那就是删除背景view [[self.searchBar.subviews objectAtIndex:0] removeFromSuperview]; 5.iOS8后本地通知设置 http://blog.csdn.net/woaifen3344/article/details/44302635

6.录音设置 ``` recordSetting = [[NSMutableDictionary alloc]init]; //设置录音格式 AVFormatIDKey==kAudioFormatLinearPCM [recordSetting setValue:[NSNumber numberWithInt:kAudioFormatMPEG4AAC] forKey:AVFormatIDKey]; //设置录音采样率(Hz) 如:AVSampleRateKey==8000/44100/96000(影响音频的质量) [recordSetting setValue:[NSNumber numberWithFloat:44100] forKey:AVSampleRateKey]; //录音通道数 1 或 2 [recordSetting setValue:[NSNumber numberWithInt:1] forKey:AVNumberOfChannelsKey]; //线性采样位数 8、16、24、32 [recordSetting setValue:[NSNumber numberWithInt:16] forKey:AVLinearPCMBitDepthKey]; //录音的质量 [recordSetting setValue:[NSNumber numberWithInt:AVAudioQualityHigh] forKey:AVEncoderAudioQualityKey]; // recordSetting = [[NSDictionary alloc] initWithObjectsAndKeys: // // [NSNumber numberWithFloat: 44100.0],AVSampleRateKey, //采样率 // // [NSNumber numberWithInt: kAudioFormatLinearPCM],AVFormatIDKey, // // [NSNumber numberWithInt:16],AVLinearPCMBitDepthKey,//采认16 // // [NSNumber numberWithInt: 2], AVNumberOfChannelsKey,//通道的数目 // // [NSNumber numberWithBool:NO],AVLinearPCMIsBigEndianKey,//大端还是小端是内存的组织方式 // // [NSNumber numberWithBool:NO],AVLinearPCMIsFloatKey,nil]; // NSString *strUrl = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]; //recordedFile=[NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/lll.aac", strUrl]]; recordedFile = [NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingPathComponent: [NSString stringWithFormat: @"%.0f.%@", [NSDatetimeIntervalSinceReferenceDate] * 1000.0, @"aac"]]]; //文件名的设置 // tmpFile = [NSURL fileURLWithPath:[NSTemporaryDirectory() stringByAppendingString:@"RecordedFile"]]; [[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayAndRecorderror: nil]; NSError *error = nil; recorder = [[AVAudioRecorder alloc] initWithURL:recordedFilesettings:recordSetting error:&error]; if (recorder!= nil) { recorder.delegate = self; if ([recorder prepareToRecord] == YES&&[recorder record]==YES) { NSLog(@"录制声音开始!"); } else { NSLog(@"录制失败!%@",error); int errorCode = CFSwapInt32HostToBig ([error code]); NSLog(@"Error: %@ [%4.4s])" , [error localizedDescription], (char*)&errorCode); } } else { NSLog(@"auioRecorder实例创建失败!"); }



```