微信语音idk的demo学习

微信语音idk的demo学习
1。 if ([[[UIDevice currentDevice]systemVersion]floatValue]>=7) {
NSLog(@”%f”,[[[UIDevice currentDevice]systemVersion] floatValue]);
//ios5用了会出错
[nc.navigationBar setBackgroundImage:[UIImage imageNamed:@”head.png”] forBarMetrics:UIBarMetricsDefault];
}
(1)获取iPhone的系统信息使用[UIDevice currentDevice]
+ (UIDevice *)currentDevice方法返回一个代表当前设备的单例对象。
[[[UIDevice currentDevice]systemVersion] floatValue]中floatvalue将一个字符串作为浮点型。
(2)- (void)setBackgroundImage:(UIImage *)backgroundImage forBarMetrics:(UIBarMetrics)barMetrics
setBackgroundImage方法的第二个参数,需要解释一下:
UIBarMetricsDefault:用竖着(拿手机)时UINavigationBar的标准的尺寸来显示UINavigationBar
UIBarMetricsLandscapePhone:用横着时UINavigationBar的标准尺寸来显示UINavigationBar
(3)导航条的使用
**获取导航条
UINavigationBar *navBar = self.navigationController.navigationBar;
**设置导航条样式(使用系统自带样式)
[navBar setBarStyle:UIBarStyleDefault];
分别有如下几种样式:
typedef NS_ENUM(NSInteger, UIBarStyle) {
    UIBarStyleDefault          = 0,
    UIBarStyleBlack            = 1,
    UIBarStyleBlackOpaque      = 1, // Deprecated. Use UIBarStyleBlack
    UIBarStyleBlackTranslucent = 2, // Deprecated. Use UIBarStyleBlack and set the translucent property to YES
};
注意:我们发现,在后面两个标记为Deprecated,我们知道使用后面两种将不被提倡。
从枚举中,我们也可以看出:UIBarStyleBlack=1和UIBarStyleBlackOpaque=1表示为一样的。
后来,发现增加了一个方法:[navBar setTranslucent:YES];用来指示是否透明。
所以,我们使用UIBarStyleDefault和UIBarStyleBlack来定义UINavigationBar样式,并且用setTranslucent:方法来设置透明与否。
2.UIimagePickerController
(1)简介
官方:The UIImagePickerController class manages customizable, system-supplied user interfaces for taking pictures and movies on supported devices, and for choosing saved images and movies for use in your app. An image picker controller manages user interactions and delivers the results of those interactions to a delegate object.
简言之,UIImagePickerController从拍照、图库、相册获取图片
(2)使用
UIImagePickerController 是系统提供的用来获取图片和视频的接口;UIImagePickerController的使用步骤。
*初始化UIImagePickerController的实力对象
*设置代理
*设置UIImagePickerController实例的数据来源类型。
---------------

UIImagePickerController的数据来源有三种
enum {
   UIImagePickerControllerSourceTypePhotoLibrary ,//来自图库
   UIImagePickerControllerSourceTypeCamera ,//来自相机
   UIImagePickerControllerSourceTypeSavedPhotosAlbum //来自相册
};
------注意-----------
1]最好判断一下是否支持
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
    {
        NSLog(@”支持相机”);
    }
    if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary])
    {
        NSLog(@”支持图库”);
    }
    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeSavedPhotosAlbum])
    {
        NSLog(@”支持相片库”);
    }
例如:
UIImagePickerController *picker = [[[UIImagePickerController alloc] init] autorelease];
picker.delegate = self;
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.allowsEditing = YES;
} else if ( [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
// picker.allowsEditing = YES;
}
2]使用UIImagePickerController,就必须实现UINavigationControllerDelegate这个protocol, 因为调用过程中会出现NavigationBar,如果没实现,也不会说运行不了。只是Xcode会直接就给你一个warning.

(3)- (void)imagePickerController:(UIImagePickerController )picker didFinishPickingMediaWithInfo:(NSDictionary )info。当得到照片或者视频后,调用该方法

3.NSObject类的performSelectorOnMainThread和performSelectorInBackground可以实现简单的多线程编程技术
1、- (void)performSelectorInBackground:(SEL)aSelector withObject:(id)arg
创建一个线程在子线程执行,aSelector代表了新创建的线程,arg是传入的参数
2、- (void)performSelectorOnMainThread:(SEL)aSelector withObject:(id)arg waitUntilDone:(BOOL)wait;
该方法的作用是在主线程中,执行制定的方法(代码块)。
参数:
@selector就是,要定义我们要执行的方法。
withObject:arg定义了,我们执行方法时,传入的参数对象。类型是id。(我们可以传入任何参数)
waitUntilDone:YES指定,当前线程是否要被阻塞,直到主线程将我们制定的代码块执行完。
注意:
1.当前线程为主线程的时候,waitUntilDone:YES参数无效。
2.该方法,没有返回值
3.该方法主要用来用主线程来修改页面UI的状态。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

程序员的修养

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值