3Gshare的总结

第一部分  登录注册页面

实现账号的登录注册,这里用到属性传值和协议传值,开始只用到协议传值,将注册的账号密码传到登录界面并存在两个数组,进行账号的登录,由于在注册页面没有判断账号有没注册,又用到属性传值将两个数组传回注册页面。

- (void)pressBtn1 {
    RegisterViewController* registerView = [[RegisterViewController alloc] init];
    registerView.array1 = [NSMutableArray array];
    registerView.array2 = [NSMutableArray array];
    [registerView.array1 addObjectsFromArray:self.array1];
    [registerView.array2 addObjectsFromArray:self.array2];
    //NSLog(@"%@", self.array1[0]);
    registerView.modalPresentationStyle = 0;
    registerView.delegate = self;
    [self presentViewController:registerView animated:YES completion:nil];
}
- (void) pressNext {
    
    if ([self.textFiled1.text isEqualToString:@""] == YES || [self.textFiled2.text isEqualToString:@""] == YES || [self.textFiled.text isEqualToString:@""] == YES)
    {
        
        self.alert = [UIAlertController alertControllerWithTitle:@"警告⚠️" message:@"输入项不能为空" preferredStyle:UIAlertControllerStyleAlert];
        UIAlertAction* action = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction* action) {}];
        [self.alert addAction:action];
        [self presentViewController:self.alert animated:YES completion:nil];
        
        [self.delegate registerReturn:self.textFiled1.text andPass:self.textFiled2.text];
    } else {
        for (int i = 0; i < self.array1.count; i++) {
            NSLog(@"----");
            NSLog(@"%@", self.array1[i]);
            if ([self.textFiled1.text isEqualToString:self.array1[i]]) {
                self.alert = [UIAlertController alertControllerWithTitle:@"" message:@"账号已注册" preferredStyle:UIAlertControllerStyleAlert];
                UIAlertAction* action = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction* action) {}];
                [self.alert addAction:action];
                [self presentViewController:self.alert animated:YES completion:nil];
                return;
            }
        }
        [self.delegate registerReturn:self.textFiled1.text andPass:self.textFiled2.text];
        [self dismissViewControllerAnimated:YES completion:nil];
        
    }
    
}

 第二部分 share页面

无限录播图,这里实现了自动轮播和手动轮播混用。在手动滑动的时候要让定时器停止。

- (void)timer {
    int num = _sv.contentOffset.x / 373;
    [self.sv setContentOffset:CGPointMake(373 * (num + 1), 0) animated:YES];
    if (num == 5) {
        self.sv.contentOffset  = CGPointMake(373, 0);
    }
}
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
        [self.mytimer invalidate];
        //self.mytimer = nil;
}
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
        self.mytimer = [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(timer) userInfo:nil repeats:YES];
}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
    if (self.sv.contentOffset.x == 373 * 5) {
        self.sv.contentOffset = CGPointMake(373 * 1, 0);
    }
    if (self.sv.contentOffset.x == 0) {
        self.sv.contentOffset = CGPointMake(373 * 4, 0);
    }
}

这里也要多加两张图。

作品的点赞同步也用到属性传值和协议传值,和上面登录注册相似。

第三部分 上传界面 

选中多张照片,在上传界面显示第一张,并显示照片的数量。

先在照片墙页面将选中的照片存在一个数组,在将数组协议传值到上传界面,在上传界面,获取数组的第一张照片和照片的数量。

- (void) pressTap:(UIGestureRecognizer*) tap {
    self.imageView = (UIImageView*) tap.view;
    for (int i = 0; i < self.array1.count; i++) {
        if ([self.array1[i] isEqual:self.imageView.image]) {
            self.alert = [UIAlertController alertControllerWithTitle:@"nil" message:@"该照片已上传" preferredStyle:UIAlertControllerStyleAlert];
            UIAlertAction* action = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction* action) {}];
            [self.alert addAction:action];
            [self presentViewController:self.alert animated:YES completion:nil];
            return;
        }
    }
    
    //[self.array addObject:self.imageView.image];
    //[self.delegate passImageView:self.imageView.image];
    if (self.imageView.tag > 100) {
        [self.array addObject:self.imageView.image];
        self.imageView1 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"choose"]];
        self.imageView1.frame = CGRectMake(107, 0, 20, 20);
        self.imageView1.tag = 1;
        [self.imageView addSubview:self.imageView1];
        self.imageView.tag = self.imageView.tag - 100;
    } else {
        for (UIImageView *view in self.imageView.subviews) {
                    if (view.tag == 1) {
                        [view removeFromSuperview];
                    }
                }
        [self.array removeObject:self.imageView.image];
        self.imageView.tag += 100;
    }
    
}
- (void) pressRight {
    [self.delegate passImage:self.array];
    self.alert = [UIAlertController alertControllerWithTitle:@"操作完成" message:@"上传成功" preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction* action = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction* action) {}];
    [self.alert addAction:action];
    [self presentViewController:self.alert animated:YES completion:nil];
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)passImage:(NSMutableArray*)array {
    [self.array1 addObjectsFromArray:array];
    self.label1 = [[UILabel alloc] init];
    self.view1 = [[UIView alloc] init];
    self.view1.backgroundColor = [UIColor yellowColor];
    self.view1.frame = CGRectMake(196.5, 110, 20, 20);
    [self.view addSubview:self.view1];
    self.label1.text = [NSString stringWithFormat:@"%ld",self.array1.count];
    self.label1.tintColor = [UIColor blackColor];
    self.label1.frame = CGRectMake(2, 2, 15, 15);
    self.imageView1 = [[UIImageView alloc] initWithImage:self.array1[0]];
    self.imageView1.frame = CGRectMake(10, 110, 206.5, 150);
    [self.view addSubview:self.imageView1];
    [self.view addSubview:self.view1];
    [self.view1 addSubview:self.label1];
    
}

  这里还用到属性传值判断多次上传时,不能选中同一照片。

-  (void)pressBtn4 {
    PictureViewController* pictureView  = [[PictureViewController alloc] init];
    pictureView.array1 = [NSMutableArray array];
    [pictureView.array1 addObjectsFromArray:self.array1];
    pictureView.delegate = self;
    [self.navigationController pushViewController:pictureView animated:YES];
}

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值