贴子发表中的图片分割

#import "EditContentsViewController.h"

#import "UIBarButtonItem+Common.h"

#import "EditContentsView.h"

#import "HotGroup.h"

#import "ActionSheetView.h"

#import "UserTool.h"


@interface EditContentsViewController ()


@property (nonatomic, strong) NSMutableArray *imageUrlMuArr;

@property (nonatomic ,strong) NSArray *hotGroupArray;

@property (nonatomic ,strong) HotGroup *hotGroup;

@property (nonatomic ,weak) EditContentsView *headerView;

@property(nonatomic ,strong) NSMutableArray *enIStrMuArr;


@end


@implementation EditContentsViewController


- (void)viewDidLoad {

    [super viewDidLoad];

   

    self.title = @"编辑内容";

    self.navigationItem.rightBarButtonItem = [UIBarButtonItem itemWithTitle:@"发表" target:self action:@selector(editAction) font:font(Font15) color:c255255255 highlightColor:c255255255];

    

    EditContentsView *headerView = [[EditContentsView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, px(610))];

    

    __weak typeof (self) weakSelf = self;

    headerView.selectBlock = ^()

    {

        

        [ weakSelf showActionSheetViewWithTaskModelArray:self.hotGroupArray];

    };

    self.headerView = headerView;

    [self.view addSubview:headerView];

    

}



-(void)editAction

{

    if (!self.headerView.titleTextField.text.length) {

        

        [MBProgressHUD showError:@"请输入标题!"];

        return;

    }

    

    if (!self.headerView.descView.descriptionTV.text.length) {

        

        [MBProgressHUD showError:@"请输入帖子内容!"];

        return;

    }

    

    if (!self.hotGroup.cid.length) {

        

        [MBProgressHUD showError:@"请选择群组!"];

        return;

        

    }

    

    if (self.headerView.photos.count) {

        

        for (UIImage *image in self.headerView.photos) {

        

        NSData *data = UIImageJPEGRepresentation(image, 1.0f);

        

        NSString *encodedImageStr = [data base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength];

        [self.enIStrMuArr addObject:encodedImageStr];

        

        }

       

    }

    

    [self  submitPost];

    

}


-(void) submitPost

{

    


    NSMutableDictionary *params = [NSMutableDictionary dictionary];

    params[@"title"] = self.headerView.titleTextField.text;

    params[@"content"] = self.headerView.descView.descriptionTV.text;

    params[@"qz_id"] = self.hotGroup.cid;

    params[@"username"] = [UserTool user].userid;

    params[@"img"] = [self.enIStrMuArr componentsJoinedByString:@"|"];

    

    [MBProgressHUD showMessage:@"帖子发表中..."];

    

    [HttpTool postWithURL:sendUser_ftForum params:params success:^(id json) {

        

        ICLog(@"json menu:%@",json);

        

        if (jsonMsg(json))

        {

            

            [MBProgressHUD showSuccess:@"成功,审核中...."];

            [self.navigationController popViewControllerAnimated:YES];

        }

        else

        {

            [MBProgressHUD showError:json[@"msg"]];

            

        }

        

        kHideHUDAll;

    } failure:^(NSError *error) {

        

        netWorkError;

        kHideHUDAll;

    }];


}

-(void)loadData

{

    kshowMessage(@"数据加载中");

    NSMutableDictionary *params = [NSMutableDictionary dictionary];

    

    [HttpTool postWithURL:getHotqzForum params:params success:^(id json) {

        

        

        

        if (jsonMsg(json)) {

            

            self.hotGroupArray = [HotGroup mj_objectArrayWithKeyValuesArray:json[@"data"]];

        }

        kHideHUDAll;

        

    } failure:^(NSError *error) {

        netWorkError;

        kHideHUDAll;

    }];

}


#pragma mark  弹出视图

- (void)showActionSheetViewWithTaskModelArray:(NSArray *)taskModelArray

{

    

   ActionSheetView *sheet = [[ActionSheetView alloc] initWithList:taskModelArray height:0 type: ActionSheetViewTypeHotGroup];

    

    __weak typeof (self) weakSelf = self;


    sheet.selectRowAtIndex = ^(NSInteger index)

    {

        weakSelf.hotGroup  = weakSelf.hotGroupArray[index];

       

    };


    [sheet showInView:nil];

}


-(NSMutableArray *)enIStrMuArr

{

    if (!_enIStrMuArr) {

        

        _enIStrMuArr = [NSMutableArray new];

    }

    return _enIStrMuArr;

}

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值