蓝懿ios 技术内容交流和学习心得 11.24

今天老师病了   我们在复习一下这几天讲的基础内容:

从相册获取图片进行编辑

 

1、搭建界面,添加按钮进行关联

2、从点击按钮跳转到相册的界面

3、选择将要跳转下一页面

4、已经完成选择图片

 

@property (nonatomic, strong)UIScrollView *sv;

@property (nonatomic, strong)NSMutableArray *seletedIVs;

@end

 

@implementation ViewController

- (IBAction)clicked:(id)sender {

    

     self.seletedIVs = [NSMutableArray array];

    

    UIImagePickerController *ipc = [[UIImagePickerController alloc]init];

    ipc.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

    ipc.delegate = self;

    //是否允许编辑

//    ipc.allowsEditing = YES;

    [self presentViewController:ipc animated:YES completion:nil];

    

    

    

}

- (void)viewDidLoad {

    [super viewDidLoad];

    

   

    

}

 

- (void)didReceiveMemoryWarning {

    [super didReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}

 

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{

    

    NSLog(@"%@",UIImagePickerControllerOriginalImage);

    NSLog(@"%@",@"UIImagePickerControllerOriginalImage");

    

    UIImage *image = info[UIImagePickerControllerOriginalImage];

//    通过数组计数 让图片的x轴和数组的数量建立关系

    UIImageView *iv = [[UIImageView alloc]initWithFrame:CGRectMake(self.seletedIVs.count*80, 0, 80, 80)];

    iv.image = image;

    [self.sv addSubview:iv];

    //打开交互

    iv.userInteractionEnabled = YES;

//    往图片中添加删除按钮

    UIButton *btn = [[UIButton alloc]initWithFrame:CGRectMake(60, 0, 20, 20)];

    [btn setTitle:@"X" forState:UIControlStateNormal];

    [btn addTarget:self action:@selector(deleteAction:) forControlEvents:UIControlEventTouchUpInside];

    [iv addSubview:btn];

    

    

    [self.seletedIVs addObject:iv];

    

    [self.sv setContentSize:CGSizeMake(self.seletedIVs.count*80, 0)];

    

//    [self dismissViewControllerAnimated:YES completion:nil];

    

}

 

-(void)deleteAction:(UIButton *)btn{

    //拿到按钮所在的图片

    UIImageView *iv = (UIImageView *)btn.superview;

    //从数组中删除

    [self.seletedIVs removeObject:iv];

    // 从界面中删除

    [iv removeFromSuperview];

    

    for (int i=0; i<<span se-mark="1">self.seletedIVs.count; i++) {

        UIImageView *iv = self.seletedIVs[i];

        [UIView animateWithDuration:.5 animations:^{

            iv.frame = CGRectMake(i*80, 0, 80, 80);

        }];

        

    }

    

    

    

    

    

}

 

- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController*)viewController animated:(BOOL)animated{

    

    if (navigationController.viewControllers.count==2) {

        UIView *v = [[UIView alloc]initWithFrame:CGRectMake(0, 567, 375, 100)];

        v.backgroundColor = [UIColor redColor];

        [viewController.view addSubview:v];

        

        self.sv = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 20, 375, 80)];

        self.sv.backgroundColor = [UIColor blueColor];

        [v addSubview:self.sv];

        

        //添加返回按钮

        UIButton *doneBtn = [[UIButton alloc]initWithFrame:CGRectMake(295, 0, 80, 20)];

        [doneBtn setTitle:@"Done" forState:UIControlStateNormal];

        [doneBtn addTarget:self action:@selector(finishAction:) forControlEvents:UIControlEventTouchUpInside];

        [v addSubview:doneBtn];

    }

    

   

    

    

    

}

 

-(void)finishAction:(UIButton*)btn{

    

    [self dismissViewControllerAnimated:YES completion:nil];

}

1、先在文件中导入#import 

 2、声明属性:@property

 (nonatomic, 

strong

)AVAudioPlayer *player;

3:生成URL,此url为在本地的路径,不能为链接;

4、让self.player =[[AVAudioPlayer alloc]initWithContentsOfURL:url error:nil];

5、调用AVAudioPlayer中的一些基本方法;

6、AVAudioPlayer自身有一个协议,其中有播放完成的方法:- (void)audioPlayerDidFinishPlaying:(AVAudioPlayer*)playersuccessfully:(BOOL)flag;

下边为AVAudioPlayer中的一些基本方法:

#import"ViewController.h"

#import

@interface

 ViewController()

@property

 (nonatomic,strong)AVAudioPlayer *player;

@end

@implementationViewController

- (void)viewDidLoad {

   [super viewDidLoad];

 

   NSURL *url = [NSURLfileURLWithPath:@"/Users/ivan/Downloads/爱拼才会贏.mp3"];

   self.player = [[AVAudioPlayeralloc]initWithContentsOfURL:url error:nil];

   //准备播放

//   [self.player prepareToPlay];

   

   [self.player play];

   //停止

//   [self.player stop];

   //暂停

//   [self.player pause];

//   播放时间

//   self.player.currentTime = 30;

//   总时间

   NSLog(@"%f",self.player.duration);

   self.player.volume = 1;

   

   //判断是否在播放

//   if (self.player.isPlaying) {     

//   }

学习ios  重要还是要理清楚思路  在做或者看老师代码的时候 自己多想想为什么  不要自己看着就抄       另外还是要推荐一下 蓝懿IOS这个培训机构  和刘国斌老师刘国斌老师还是很有名气的,听朋友说刘老师成立了蓝懿iOS,,老师讲课方式很独特,能够尽量让每个人都能弄明白,有的比较难懂的地方,如果有的地方还是不懂得话,老师会换个其它方法再讲解,这对于我们这些学习iOS的同学是非常好的,多种方式的讲解会理解得更全面,这个必须得给个赞,嘻嘻,还有就是这里的学习环境很好,很安静,可以很安心的学习,安静的环境是学习的基础,小班讲课,每个班20几个学生,学习氛围非常好,每天都学到9点多才离开教室,练习的时间很充裕,而且如果在练习的过程中有什么困难,随时可以向老师求助,不像其它机构,通过视频教学,有的甚至学完之后都看不到讲师本人,问点问题都不方便,这就是蓝懿与其它机构的区别,相信在刘国斌老师的细心指导下,每个蓝懿学员都能找到满意的工作,加油!

                                                                  写博客第四十五天;

                                                                              QQ:565803433​


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值