因为工做需求,须要开发一个相似的朋友圈功能,用于工做汇报。
ios
一、地理信息获取,我采用了高德api 文档以下 (这个仍是简单的,定位方便)git
#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包含了地址信息 打印下就能够获取 } }]; }
二、选择相机及相册 (具体代码能够看我以前的文章)github
三、图片上传 (这快我搞了好久,一直都不明白,采用二进制的方式,这里也参考我以前的单独文章)web
四、点击图片放大(这个也搞了好久,==!)api
//思路 //一、先获取原图的位置。 //二、点击图片后,图片居中 这里加载2层,一层背景 一层图片。我用了AFNetworking 2.6版本的 //三、异步加载图片,我这里用了SDWebImage 就简单了 //四、进度条要的吧,一开始用了webview 效果很烂(放弃了) 后来用SDProgressView //五、点击放大 而后缩回去,记住用图片和背景都添加在window上 是并列关系。否则缩放的时候问题大大的。
五、文本高度问题。异步
//工做日志 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];
六、图片高度问题 这里要说明白的是,上传图片到后台,要存储缩略图的宽和高。而后获取图片的时候,先把图片大小设置好。spa
#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/code
https://github.com/AFNetworking/AFNetworking blog
https://github.com/gsdios/SDProgressView
https://github.com/rs/SDWebImage