#import "AFHttpManager.h"
@interface EditGroupInfoViewController () <UIActionSheetDelegate,UIImagePickerControllerDelegate,UINavigationControllerDelegate>
/**
跑團名稱
*/
@property (weak, nonatomic) IBOutlet UITextView *groupNameTextView;
/**
跑團城市
*/
@property (weak, nonatomic) IBOutlet UITextView *groupCityTextView;
/**
跑團頭像
*/
@property (weak, nonatomic) IBOutlet UIImageView *groupImageView;
/**
跑團宣言
*/
@property (weak, nonatomic) IBOutlet UITextView *groupManifestoTextView;
@end
@implementation EditGroupInfoViewController
{
NSData *imageData;
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
DLog(@"編輯跑團界面");
// self.title = @"編輯跑團";
self.navigationController.title = @"編輯跑團";
//MARK:需要修改圓形圖標(biāo)
_groupImageView.layer.cornerRadius = _groupImageView.bounds.size.width/2;
_groupImageView.layer.masksToBounds = YES;
[self changeTextView:self.groupCityTextView];
[self changeTextView:self.groupNameTextView];
[self changeTextView:self.groupManifestoTextView];
}
#pragma mark - textView設(shè)置邊框
- (void)changeTextView:(UITextView *)textView {
textView.layer.borderColor = [[UIColor colorWithRed:215.0 / 255.0 green:215.0 / 255.0 blue:215.0 / 255.0 alpha:1] CGColor];
textView.layer.borderWidth = 0.6f;
textView.layer.cornerRadius = 6.0f;
}
- (IBAction)upIamgeViewAction:(id)sender {
DLog(@"上傳頭像");
UIActionSheet *myActionSheet = [[UIActionSheet alloc]initWithTitle:nil delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:CustomLocalizedString(@"OpenCamera", nil),CustomLocalizedString(@"AlbumSelection",nil), nil];
[myActionSheet showInView:self.view];
}
#pragma mark-actionSheet協(xié)議方法
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == actionSheet.cancelButtonIndex) {
NSLog(@"取消");
}
switch (buttonIndex) {
case 0:
{
//打開相機
[self takePhoto];
}
break;
case 1:
{
//打開相冊
[self openPhoto];
}
break;
default:
break;
}
}
//打開相機
-(void)takePhoto{
UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypeCamera;
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
UIImagePickerController *picker = [[UIImagePickerController alloc]init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = sourceType;
[self presentViewController:picker animated:YES completion:nil];
}else{
NSLog(@"模擬器無法打開照相機涡戳,請在真機中使用");
}
}
//打開相冊
-(void)openPhoto{
UIImagePickerController *picker = [[UIImagePickerController alloc]init];
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
picker.delegate = self;
picker.allowsEditing = YES;
[self presentViewController:picker animated:YES completion:nil];
}
#pragma mark-圖片選擇協(xié)議方法
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
NSString *type = [info objectForKey:UIImagePickerControllerMediaType];
UIImage *image;
if ([type isEqualToString:@"public.image"]) {
image = [info objectForKey:@"UIImagePickerControllerEditedImage"];
NSData *data = [NSData data];
if (UIImagePNGRepresentation(image)==nil) {
data = UIImageJPEGRepresentation(image, 0.1);
imageData = data;
}else{
data = UIImagePNGRepresentation(image);
imageData = data;
}
//MARK:這里要修改為上傳群組的頭像
// [self requestimagedata];
//將剪裁后的圖片放到ImageView上
[picker dismissViewControllerAnimated:YES completion:^{
self.groupImageView.image = image; _groupImageView.clipsToBounds = YES;
}];
}else{
[picker dismissViewControllerAnimated:YES completion:^{
NSLog(@"上傳頭像失敗");
}];
}
}
#pragma mark - 服務(wù)器長傳圖片的方法,注意是群組圖片
-(void)requestimagedata
{
NSMutableDictionary *dic = [NSMutableDictionary dictionary];
[dic setValue:[ToolUtils readToken] forKey:@"token"];
[dic setValue:@"6" forKey:@"type"];
//MainUrl(@"/service/show/serviceInfoByWhere")
[AFHttpManager postUploadWithUrl:MainUrl(@"/users/login/uploadPic") fileUrl:imageData parameter:dic success:^(id responseObject) {
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:[NSString stringWithFormat:@"%@UserListbool" ,[[NSUserDefaults standardUserDefaults] objectForKey:@"identifySaves"]]];
[[NSUserDefaults standardUserDefaults] synchronize];
} failure:^(NSError *error) {
}];
}
-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
[picker dismissViewControllerAnimated:YES completion:nil];
}
#pragma mark - 完成
- (IBAction)didAccomplishAction:(id)sender {
DLog(@"點擊完成按鈕");
[self.navigationController popViewControllerAnimated:YES];
}
設(shè)置圖片選擇器
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
- 文/潘曉璐 我一進店門绊谭,熙熙樓的掌柜王于貴愁眉苦臉地迎上來政恍,“玉大人,你說我怎么就攤上這事达传「Ю” “怎么了?”我有些...
- 文/不壞的土叔 我叫張陵趟大,是天一觀的道長鹤树。 經(jīng)常有香客問我,道長逊朽,這世上最難降的妖魔是什么罕伯? 我笑而不...
- 正文 為了忘掉前任,我火速辦了婚禮叽讳,結(jié)果婚禮上追他,老公的妹妹穿的比我還像新娘。我一直安慰自己岛蚤,他們只是感情好邑狸,可當(dāng)我...
- 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著涤妒,像睡著了一般单雾。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上,一...
- 文/蒼蘭香墨 我猛地睜開眼疯潭,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了面殖?” 一聲冷哼從身側(cè)響起竖哩,我...
- 正文 年R本政府宣布虽画,位于F島的核電站舞蔽,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏码撰。R本人自食惡果不足惜渗柿,卻給世界環(huán)境...
- 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望脖岛。 院中可真熱鬧朵栖,春花似錦、人聲如沸柴梆。這莊子的主人今日做“春日...
- 文/蒼蘭香墨 我抬頭看了看天上的太陽绍在。三九已至门扇,卻和暖如春雹有,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背悯嗓。 一陣腳步聲響...
推薦閱讀更多精彩內(nèi)容
- 示例: 獲取屬性 - attr() jQuery attr() 方法用于獲取屬性值降铸。 //獲取屬性值 1 JQUE...