iOS小记

来源:互联网 发布:免费摇号软件 编辑:程序博客网 时间:2024/05/16 05:09

1.iOS切换使用http : 

<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
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 怎样去掉背景的颜色(storyboard里只能设置background颜色,可是发现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:kAudioFormatMPEG4AACforKey:AVFormatIDKey];

    //设置录音采样率(Hz) 如:AVSampleRateKey==8000/44100/96000(影响音频的质量)

    [recordSetting setValue:[NSNumber numberWithFloat:44100forKey:AVSampleRateKey];

    //录音通道数  1  2

    [recordSetting setValue:[NSNumber numberWithInt:1forKey:AVNumberOfChannelsKey];

    //线性采样位数  8162432

    [recordSetting setValue:[NSNumber numberWithInt:16forKey:AVLinearPCMBitDepthKey];

    //录音的质量

    [recordSetting setValue:[NSNumber numberWithInt:AVAudioQualityHighforKey: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 sharedInstancesetCategoryAVAudioSessionCategoryPlayAndRecorderrornil];

    

    NSError *error = nil;

    recorder = [[AVAudioRecorder allocinitWithURL: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实例创建失败!");

    }



```

1 0
原创粉丝点击