ios 微信朋友圈 开发技术分析

本文详细介绍了一个类似朋友圈功能的开发过程,包括使用高德API进行地理信息获取、选择相机及相册功能实现、图片上传和展示的技术细节,以及文本和图片自适应高度的处理方法。

由于工作需求,需要开发一个类似的朋友圈功能,用于工作汇报。


1、地理信息获取,我采用了高德api   文档如下  (这个还是简单的,定位方便)

#import <AMapLocationKit/AMapLocationKit.h>

- (void)dingwei {
    
    [_textView resignFirstResponder];
    
    [AMapLocationServices sharedServices].apiKey =@"这里是你申请的token";
    locationManager = [[AMapLocationManager alloc] init];
    locationManager.delegate = self;
    
    [locationManager setDesiredAccuracy:kCLLocationAccuracyHundredMeters];
    
    
    // 带逆地理(返回坐标和地址信息)
    [locationManager requestLocationWithReGeocode:YES completionBlock:^(CLLocation *location, AMapLocationReGeocode *regeocode, NSError *error) {
        
        if (error)
        {
            NSLog(@"locError:{%ld - %@};", (long)error.code, error.localizedDescription);
            self.addressLabel.text=error.localizedDescription;
        }
        
        if (regeocode)
        {
            //regcode包含了地址信息 打印下就可以获取

        }
        
        
    }];
    
}



2、选择相机及相册 (具体代码可以看我之前的文章)

3、图片上传 (这快我搞了很久,一直都不明白,采用二进制的方式,这里也参考我之前的单独文章)

4、点击图片放大(这个也搞了很久,==!)

//思路
//1、先获取原图的位置。
//2、点击图片后,图片居中  这里加载2层,一层背景 一层图片。我用了AFNetworking 2.6版本的
//3、异步加载图片,我这里用了SDWebImage 就简单了
//4、进度条要的吧,一开始用了webview 效果很烂(放弃了) 后来用SDProgressView
//5、点击放大 然后缩回去,记住用图片和背景都添加在window上 是并列关系。不然缩放的时候问题大大的。

5、文本高度问题。

  //工作日志
   UITextView * blogView=[cell viewWithTag:4];
    blogView.text=[dic objectForKey:@"content"];
    
    CGSize  size = [blogView.text sizeWithFont:[UIFont systemFontOfSize:14] constrainedToSize:CGSizeMake(240, 2000)
                                 lineBreakMode: UILineBreakModeWordWrap];
    //不允许滚动
    blogView.scrollEnabled=NO;
    
    CGRect  blogFrame=blogView.frame;
    blogFrame.size.height=size.height+10;//获取自适应文本内容高度
    blogView.frame=blogFrame;
    [blogView endEditing:NO];


6、图片高度问题  这里要说明白的是,上传图片到后台,要存储缩略图的宽和高。然后获取图片的时候,先把图片大小设置好。

#pragma mark 自适应高度
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [self tableView:_tableView cellForRowAtIndexPath:indexPath];
    
    return cell.frame.size.height;
}



参考资料:

http://lbs.amap.com/api/ios-location-sdk/summary/

https://github.com/AFNetworking/AFNetworking

https://github.com/gsdios/SDProgressView

https://github.com/rs/SDWebImage


转载于:https://my.oschina.net/u/554046/blog/631354

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值