由于工作需求,需要开发一个类似的朋友圈功能,用于工作汇报。
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