标签:
#import "BaseView.h"
#import "UIImage+resize.h"
#import "NSString+Check.h"
#import "UIButton+WebCache.h"
#define kOne 10
#define kTwo 20
#define kThree 30
#define kFour 40
#define kLicenceBtn 200
#define kRoomBtn 100
@interface BaseView()
@end
@implementation BaseView
{
MBProgressHUD *HUD;
}
-(void)awakeFromNib
{
[super awakeFromNib];
[self doInit];
[self initImageArray];
// [self resetRoomBtn];
// [self reseLicenceBtn];
self.roomImageStr = [NSMutableString string];
self.licenceImageStr = [NSMutableString string];
}
-(void)initImageArray
{
self.roomImgArray = [NSMutableArray array];
self.licenceImgArray = [NSMutableArray array];
[self.roomImgArray addObject:[self addImageInfo]];
[self.licenceImgArray addObject:[self addImageInfo]];
}
-(UIButton *)fakeBtn
{
static UIButton *fBtn;
if (!fBtn) {
fBtn = [UIButton buttonWithType:UIButtonTypeCustom];
}
return fBtn;
}
-(void)doInit
{
self.inputBg01.layer.cornerRadius = kCornerRadius;
self.inputBg01.layer.borderWidth = 1;
self.inputBg01.layer.borderColor = RGBCOLOR(170, 170, 170).CGColor;
self.inputBg02.layer.cornerRadius = kCornerRadius;
self.inputBg02.layer.borderWidth = 1;
self.inputBg02.layer.borderColor = RGBCOLOR(170, 170, 170).CGColor;
self.inputBg03.layer.cornerRadius = kCornerRadius;
self.inputBg03.layer.borderWidth = 1;
self.inputBg03.layer.borderColor = RGBCOLOR(170, 170, 170).CGColor;
self.inputBg04.layer.cornerRadius = kCornerRadius;
self.inputBg04.layer.borderWidth = 1;
self.inputBg04.layer.borderColor = RGBCOLOR(170, 170, 170).CGColor;
self.inputBg05.layer.cornerRadius = kCornerRadius;
self.inputBg05.layer.borderWidth = 1;
self.inputBg05.layer.borderColor = RGBCOLOR(170, 170, 170).CGColor;
self.inputBg06.layer.cornerRadius = kCornerRadius;
self.inputBg06.layer.borderWidth = 1;
self.inputBg06.layer.borderColor = RGBCOLOR(170, 170, 170).CGColor;
self.inputBg07.layer.cornerRadius = kCornerRadius;
self.inputBg07.layer.borderWidth = 1;
self.inputBg07.layer.borderColor = RGBCOLOR(170, 170, 170).CGColor;
self.inputBg08.layer.cornerRadius = kCornerRadius;
self.inputBg08.layer.borderWidth = 1;
self.inputBg08.layer.borderColor = RGBCOLOR(170, 170, 170).CGColor;
self.phoneBtn.layer.cornerRadius = 20;
}
#pragma -mark 赋值的逻辑在view里面实现
-(void)setInfo:(StoreInfo *)info
{
_info = info;
self.addressFiled.text = info.address;
self.mctNameFiled.text = info.name;
self.categoryFiled.text = info.category;
self.knameFiled.text = info.linkman;
self.kIDFiled.text = info.idCardNo;
self.kRegisterFiled.text = info.businessLicenseNo;
self.kphoneFiled.text = info.phone;
self.scopeFiled.text = info.scaleDescn;
for (int i=0; (i<info.businessLicensePhoto.count && i<2); i++) {
NSString *pic = [info.businessLicensePhoto objectAtIndex:i];
ImageInfo *minfo = [[ImageInfo alloc]init];
minfo.imageUrl = pic;
[_licenceImageStr appendString:pic];
if (i!= info.businessLicensePhoto.count-1) {
[_licenceImageStr appendString:@","];
}
[self.licenceImgArray insertObject:minfo atIndex:self.licenceImgArray.count-1];
}
for (int i=0; i<info.shopPhoto.count; i++) {
NSString *pic = [info.shopPhoto objectAtIndex:i];
ImageInfo *minfo = [[ImageInfo alloc]init];
minfo.imageUrl = pic;
TTLog(@"imageurl aaaaaaaaa %d %@",i,minfo.imageUrl);
[_roomImageStr appendString:pic];
if (i!= info.businessLicensePhoto.count-1) {
[_roomImageStr appendString:@","];
}
TTLog(@"roomimageStr ...........%@",_roomImageStr);
TTLog(@"roomimageAcount ...........%d",_roomImgArray.count);
[self.roomImgArray insertObject:minfo atIndex:self.roomImgArray.count-1];
}
if (![_info.cooperationState isEqualToString:@"TALKING"]) {
[_licenceImgArray removeLastObject];
[_roomImgArray removeLastObject];
}
[self reseLicenceBtn];
[self resetRoomBtn];
}
- (void)showLoadingView
{
[self showLoadingViewWithMessage:nil];
}
- (void)showLoadingViewWithMessage:(NSString *)message
{
[self hideLoadingView];
HUD = [[MBProgressHUD alloc] initWithView:self];
[self addSubview:HUD];
HUD.labelText = message;
[HUD show:YES];
HUD.removeFromSuperViewOnHide = YES;
}
- (void)hideLoadingView
{
if (HUD)
{
[HUD hide:YES];
HUD = nil;
}
}
- (void)showToasts:(NSString*)message
{
[self showToast:message duration:2.0];
}
- (void)showToast:(NSString*)message duration:(float)seconds
{
[self makeToast:message duration:seconds position:@"bottom"];
}
-(IBAction)handleHttpResponse:(AFHTTPRequestOperation *)operation
{
NSHTTPURLResponse *mResponse = operation.response;
NSUInteger statusCode = [mResponse statusCode];
if (statusCode == 401) {
[TTCacheUtil removeObjectForName:LOGIN_TOKEN];
[self showToast:@"访问需要登陆!" duration:3.0];
[SharedAppDelegate showLogin];
}else if (statusCode == 500){
[self showToast:@"服务器内部发生错误!" duration:3.0];
}
else{
[self showToast:@"网络连接失败,请检查网络稍后重试!" duration:3.0];
}
}
-(IBAction)pressPicBtn:(UIButton *)btn
{
self.clickBtnFrom = btn.tag;
UIActionSheet *shit = [[UIActionSheet alloc]initWithTitle:@"修改头像" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"拍照" otherButtonTitles:@"相册", nil];
[shit showInView:self];
}
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex != actionSheet.cancelButtonIndex) {
UIImagePickerController* controller = [[UIImagePickerController alloc] init];
controller.delegate = self;
if (buttonIndex == 0) {
if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
return;
}
controller.sourceType = UIImagePickerControllerSourceTypeCamera;
}
else {
controller.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
}
controller.allowsEditing = YES;
[SharedAppDelegate.window.rootViewController presentViewController:controller animated:YES completion:nil];
}
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
[SharedAppDelegate.window.rootViewController dismissViewControllerAnimated:YES completion:nil];
UIImage* image = [info objectForKey:UIImagePickerControllerEditedImage];
if (image) {
image = [image imageByScalingToDefaultSize];
if (self.clickBtnFrom >=10) {//营业执照
ImageInfo *info = [[ImageInfo alloc]init];
info.mImage = image;
[self.licenceImgArray insertObject:info atIndex:self.licenceImgArray.count-1];
[self reseLicenceBtn];
}else{
ImageInfo *info = [[ImageInfo alloc]init];
info.mImage = image;
[self.roomImgArray insertObject:info atIndex:self.roomImgArray.count-1];
[self resetRoomBtn];
}
}
}
-(void)moveBtn:(NSUInteger)tag
{
[self.addPicBtn removeTarget:self action:@selector(pressPicBtn:) forControlEvents:UIControlEventTouchUpInside];
switch (tag) {
case kOne:
{
[self.oneBtn addTarget:self action:@selector(switchAction:) forControlEvents:UIControlEventTouchUpInside];
self.addPicBtn = self.twoBtn;
break;
}
case kTwo:
{
[self.twoBtn addTarget:self action:@selector(switchAction:) forControlEvents:UIControlEventTouchUpInside];
self.addPicBtn = self.threeBtn;
break;
}
case kThree:
{
[self.threeBtn addTarget:self action:@selector(switchAction:) forControlEvents:UIControlEventTouchUpInside];
self.addPicBtn = self.fourBtn;
break;
}
default:
{
[self.fourBtn addTarget:self action:@selector(switchAction:) forControlEvents:UIControlEventTouchUpInside];
self.addPicBtn = [self fakeBtn];
break;
}
}
ImageInfo *info = [self addImageInfo];
[self.addPicBtn setImage:info.mImage forState:UIControlStateNormal];
[self.addPicBtn addTarget:self action:@selector(pressPicBtn:) forControlEvents:UIControlEventTouchUpInside];
}
-(ImageInfo *)addImageInfo
{
static ImageInfo *info;
if (!info) {
info = [[ImageInfo alloc]init];
info.imageUrl = @"";
info.mImage = [UIImage imageNamed:@"image_add.png"];
}
return info;
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
[SharedAppDelegate.window.rootViewController dismissViewControllerAnimated:YES completion:nil];
}
-(IBAction)switchAction:(id)sender
{
UIButton *btn = (UIButton *)sender;
if (btn == self.addPicBtn) {
return;
}
if (!btn.imageView.image) {
return;
}
ImageInfo *info = [self addImageInfo];
if (btn.imageView.image == info.mImage) {
[self.addPicBtn removeTarget:self action:@selector(pressPicBtn:) forControlEvents:UIControlEventTouchUpInside];
[btn removeTarget:self action:@selector(pressPicBtn:) forControlEvents:UIControlEventTouchUpInside];
switch (btn.tag) {
case kOne:
{
self.addPicBtn = self.oneBtn;
break;
}
case kTwo:
{
self.addPicBtn = self.twoBtn;
break;
}
case kThree:
{
self.addPicBtn = self.threeBtn;
break;
}
default:
{
self.addPicBtn = self.fourBtn;
break;
}
}
[self.addPicBtn addTarget:self action:@selector(pressPicBtn:) forControlEvents:UIControlEventTouchUpInside];
// [self pressPicBtn];
}else{
[self showDeletePicAction:btn];
}
}
//还需要准备imagedata fuck
-(void)deletePicAction:(NSUInteger)btnIndex
{
if (btnIndex>=10) {
btnIndex -=10;
[self.licenceImgArray removeObjectAtIndex:btnIndex];
[self reseLicenceBtn];
}else{
[self.roomImgArray removeObjectAtIndex:btnIndex];
[self resetRoomBtn];
}
}
-(void)showDeletePicAction:(UIButton *)btn
{
DeletePicController *controller = [[DeletePicController alloc]init];
controller.mImage = btn.imageView.image;
controller.btnIndex = btn.tag;
controller.delegate = self;
controller.cooperationState = _info.cooperationState;
UINavigationController *navi = [[UINavigationController alloc]initWithRootViewController:controller];
[SharedAppDelegate.navigationController presentViewController:navi animated:YES completion:nil];
}
#pragma -mark something new idea
-(void)resetRoomBtn
{
[self.oneBtn removeTarget:self action:@selector(pressPicBtn:) forControlEvents:UIControlEventTouchUpInside];
[self.oneBtn removeTarget:self action:@selector(showDeletePicAction:) forControlEvents:UIControlEventTouchUpInside];
[self.twoBtn removeTarget:self action:@selector(pressPicBtn:) forControlEvents:UIControlEventTouchUpInside];
[self.twoBtn removeTarget:self action:@selector(showDeletePicAction:) forControlEvents:UIControlEventTouchUpInside];
[self.threeBtn removeTarget:self action:@selector(pressPicBtn:) forControlEvents:UIControlEventTouchUpInside];
[self.threeBtn removeTarget:self action:@selector(showDeletePicAction:) forControlEvents:UIControlEventTouchUpInside];
[self.fourBtn removeTarget:self action:@selector(pressPicBtn:) forControlEvents:UIControlEventTouchUpInside];
[self.fourBtn removeTarget:self action:@selector(showDeletePicAction:) forControlEvents:UIControlEventTouchUpInside];
NSUInteger aCount = self.roomImgArray.count;
for (int i = 0;i<aCount;i++) {
ImageInfo *info = [self.roomImgArray objectAtIndex:i];
if (info.imageUrl.length == 0) {
UIImage *image = info.mImage;
switch(aCount)
{
case 1:
{
[self.oneBtn addTarget:self action:@selector(pressPicBtn:) forControlEvents:UIControlEventTouchUpInside];
[self.oneBtn setImage:image forState:UIControlStateNormal];
self.oneBtn.hidden = NO;
self.twoBtn.hidden = YES;
self.threeBtn.hidden = YES;
self.fourBtn.hidden = YES;
break;
}
case 2:
{
if (i==0) {
[self.oneBtn addTarget:self action:@selector(showDeletePicAction:) forControlEvents:UIControlEventTouchUpInside];
[self.oneBtn setImage:image forState:UIControlStateNormal];
}else
//第二个Button
{
[self.twoBtn addTarget:self action:@selector(pressPicBtn:) forControlEvents:UIControlEventTouchUpInside];
[self.twoBtn setImage:image forState:UIControlStateNormal];
}
self.oneBtn.hidden = NO;
self.twoBtn.hidden = NO;
self.threeBtn.hidden = YES;
self.fourBtn.hidden = YES;
break;
}
case 3:
{
if (i==0) {
[self.oneBtn addTarget:self action:@selector(showDeletePicAction:) forControlEvents:UIControlEventTouchUpInside];
[self.oneBtn setImage:image forState:UIControlStateNormal];
}else if(i==1){
[self.twoBtn addTarget:self action:@selector(showDeletePicAction:) forControlEvents:UIControlEventTouchUpInside];
[self.twoBtn setImage:image forState:UIControlStateNormal];
}else{
[self.threeBtn addTarget:self action:@selector(pressPicBtn:) forControlEvents:UIControlEventTouchUpInside];
[self.threeBtn setImage:image forState:UIControlStateNormal];
}
self.oneBtn.hidden = NO;
self.twoBtn.hidden = NO;
self.threeBtn.hidden = NO;
self.fourBtn.hidden = YES;
break;
}
case 4:
{
if (i==0) {
[self.oneBtn addTarget:self action:@selector(showDeletePicAction:) forControlEvents:UIControlEventTouchUpInside];
[self.oneBtn setImage:image forState:UIControlStateNormal];
}else if(i==1){
[self.twoBtn addTarget:self action:@selector(showDeletePicAction:) forControlEvents:UIControlEventTouchUpInside];
[self.twoBtn setImage:image forState:UIControlStateNormal];
}else if(i==2){
[self.threeBtn addTarget:self action:@selector(showDeletePicAction:) forControlEvents:UIControlEventTouchUpInside];
[self.threeBtn setImage:image forState:UIControlStateNormal];
}else{
[self.fourBtn addTarget:self action:@selector(pressPicBtn:) forControlEvents:UIControlEventTouchUpInside];
[self.fourBtn setImage:image forState:UIControlStateNormal];
}
self.oneBtn.hidden = NO;
self.twoBtn.hidden = NO;
self.threeBtn.hidden = NO;
self.fourBtn.hidden = NO;
break;
}
default:
{
if (i==0) {
[self.oneBtn addTarget:self action:@selector(showDeletePicAction:) forControlEvents:UIControlEventTouchUpInside];
[self.oneBtn setImage:image forState:UIControlStateNormal];
}else if(i==1){
[self.twoBtn addTarget:self action:@selector(showDeletePicAction:) forControlEvents:UIControlEventTouchUpInside];
[self.twoBtn setImage:image forState:UIControlStateNormal];
}else if(i==2){
[self.threeBtn addTarget:self action:@selector(showDeletePicAction:) forControlEvents:UIControlEventTouchUpInside];
[self.threeBtn setImage:image forState:UIControlStateNormal];
}else if(i==3){
[self.fourBtn addTarget:self action:@selector(showDeletePicAction:) forControlEvents:UIControlEventTouchUpInside];
[self.fourBtn setImage:image forState:UIControlStateNormal];
}
self.oneBtn.hidden = NO;
self.twoBtn.hidden = NO;
self.threeBtn.hidden = NO;
self.fourBtn.hidden = NO;
break;
}
}
}else{
NSString *url = info.imageUrl;
switch(aCount)
{
case 1:
{
[self.oneBtn addTarget:self action:@selector(pressPicBtn:) forControlEvents:UIControlEventTouchUpInside];
[self.oneBtn sd_setImageWithURL:[NSURL URLWithString:url] forState:UIControlStateNormal];
self.oneBtn.hidden = NO;
self.twoBtn.hidden = YES;
self.threeBtn.hidden = YES;
self.fourBtn.hidden = YES;
break;
}
case 2:
{
if (i==0) {
[self.oneBtn addTarget:self action:@selector(showDeletePicAction:) forControlEvents:UIControlEventTouchUpInside];
[self.oneBtn sd_setImageWithURL:[NSURL URLWithString:url] forState:UIControlStateNormal];
}else
//第二个Button
{
[self.twoBtn addTarget:self action:@selector(pressPicBtn:) forControlEvents:UIControlEventTouchUpInside];
[self.twoBtn sd_setImageWithURL:[NSURL URLWithString:url] forState:UIControlStateNormal];
}
self.oneBtn.hidden = NO;
self.twoBtn.hidden = NO;
self.threeBtn.hidden = YES;
self.fourBtn.hidden = YES;
break;
}
case 3:
{
if (i==0) {
[self.oneBtn addTarget:self action:@selector(showDeletePicAction:) forControlEvents:UIControlEventTouchUpInside];
[self.oneBtn sd_setImageWithURL:[NSURL URLWithString:url] forState:UIControlStateNormal];
}else if(i==1){
[self.twoBtn addTarget:self action:@selector(showDeletePicAction:) forControlEvents:UIControlEventTouchUpInside];
[self.twoBtn sd_setImageWithURL:[NSURL URLWithString:url] forState:UIControlStateNormal];
}else{
[self.threeBtn addTarget:self action:@selector(pressPicBtn:) forControlEvents:UIControlEventTouchUpInside];
[self.threeBtn sd_setImageWithURL:[NSURL URLWithString:url] forState:UIControlStateNormal];
}
self.oneBtn.hidden = NO;
self.twoBtn.hidden = NO;
self.threeBtn.hidden = NO;
self.fourBtn.hidden = YES;
break;
}
case 4:
{
if (i==0) {
[self.oneBtn addTarget:self action:@selector(showDeletePicAction:) forControlEvents:UIControlEventTouchUpInside];
[self.oneBtn sd_setImageWithURL:[NSURL URLWithString:url] forState:UIControlStateNormal];
}else if(i==1){
[self.twoBtn addTarget:self action:@selector(showDeletePicAction:) forControlEvents:UIControlEventTouchUpInside];
[self.twoBtn sd_setImageWithURL:[NSURL URLWithString:url] forState:UIControlStateNormal];
}else if(i==2){
[self.threeBtn addTarget:self action:@selector(showDeletePicAction:) forControlEvents:UIControlEventTouchUpInside];
[self.threeBtn sd_setImageWithURL:[NSURL URLWithString:url] forState:UIControlStateNormal];
}else{
[self.fourBtn addTarget:self action:@selector(pressPicBtn:) forControlEvents:UIControlEventTouchUpInside];
[self.fourBtn sd_setImageWithURL:[NSURL URLWithString:url] forState:UIControlStateNormal];
}
self.oneBtn.hidden = NO;
self.twoBtn.hidden = NO;
self.threeBtn.hidden = NO;
self.fourBtn.hidden = NO;
break;
}
default:
{
if (i==0) {
[self.oneBtn addTarget:self action:@selector(showDeletePicAction:) forControlEvents:UIControlEventTouchUpInside];
[self.oneBtn sd_setImageWithURL:[NSURL URLWithString:url] forState:UIControlStateNormal];
}else if(i==1){
[self.twoBtn addTarget:self action:@selector(showDeletePicAction:) forControlEvents:UIControlEventTouchUpInside];
[self.twoBtn sd_setImageWithURL:[NSURL URLWithString:url] forState:UIControlStateNormal];
}else if(i==2){
[self.threeBtn addTarget:self action:@selector(showDeletePicAction:) forControlEvents:UIControlEventTouchUpInside];
[self.threeBtn sd_setImageWithURL:[NSURL URLWithString:url] forState:UIControlStateNormal];
}else if(i==3){
[self.fourBtn addTarget:self action:@selector(showDeletePicAction:) forControlEvents:UIControlEventTouchUpInside];
[self.fourBtn sd_setImageWithURL:[NSURL URLWithString:url] forState:UIControlStateNormal];
}
self.oneBtn.hidden = NO;
self.twoBtn.hidden = NO;
self.threeBtn.hidden = NO;
self.fourBtn.hidden = NO;
break;
}
}
}
}
if (![_info.cooperationState isEqualToString:@"TALKING"]) {
[self.oneBtn removeTarget:self action:@selector(pressPicBtn:) forControlEvents:UIControlEventTouchUpInside];
[self.twoBtn removeTarget:self action:@selector(pressPicBtn:) forControlEvents:UIControlEventTouchUpInside];
[self.threeBtn removeTarget:self action:@selector(pressPicBtn:) forControlEvents:UIControlEventTouchUpInside];
[self.fourBtn removeTarget:self action:@selector(pressPicBtn:) forControlEvents:UIControlEventTouchUpInside];
}
}
-(void)reseLicenceBtn
{
[self.kOneBtn removeTarget:self action:@selector(pressPicBtn:) forControlEvents:UIControlEventTouchUpInside];
[self.kOneBtn removeTarget:self action:@selector(showDeletePicAction:) forControlEvents:UIControlEventTouchUpInside];
[self.kTwoBtn removeTarget:self action:@selector(pressPicBtn:) forControlEvents:UIControlEventTouchUpInside];
[self.kTwoBtn removeTarget:self action:@selector(showDeletePicAction:) forControlEvents:UIControlEventTouchUpInside];
NSUInteger aCount = self.licenceImgArray.count;
for (int i = 0;i<aCount;i++) {
ImageInfo *info = [self.licenceImgArray objectAtIndex:i];
if (info.imageUrl.length == 0) {
UIImage *image = info.mImage;
switch(aCount)
{
case 1:
{
[self.kOneBtn addTarget:self action:@selector(pressPicBtn:) forControlEvents:UIControlEventTouchUpInside];
[self.kOneBtn setImage:image forState:UIControlStateNormal];
self.kOneBtn.hidden = NO;
self.kTwoBtn.hidden = YES;
break;
}
case 2:
{
if (i==0) {
[self.kOneBtn addTarget:self action:@selector(showDeletePicAction:) forControlEvents:UIControlEventTouchUpInside];
[self.kOneBtn setImage:image forState:UIControlStateNormal];
}else
//第二个Button
{
[self.kTwoBtn addTarget:self action:@selector(pressPicBtn:) forControlEvents:UIControlEventTouchUpInside];
[self.kTwoBtn setImage:image forState:UIControlStateNormal];
}
self.kOneBtn.hidden = NO;
self.kTwoBtn.hidden = NO;
break;
}
default:
{ if (i==0) {
[self.kOneBtn addTarget:self action:@selector(showDeletePicAction:) forControlEvents:UIControlEventTouchUpInside];
[self.kOneBtn setImage:image forState:UIControlStateNormal];
}else if(i==1){
[self.kTwoBtn addTarget:self action:@selector(showDeletePicAction:) forControlEvents:UIControlEventTouchUpInside];
[self.kTwoBtn setImage:image forState:UIControlStateNormal];
}
self.kOneBtn.hidden = NO;
self.kTwoBtn.hidden = NO;
break;
}
}
}else{
NSString *url = info.imageUrl;
switch(aCount)
{
case 1:
{
[self.kOneBtn addTarget:self action:@selector(pressPicBtn:) forControlEvents:UIControlEventTouchUpInside];
[self.kOneBtn sd_setImageWithURL:[NSURL URLWithString:url] forState:UIControlStateNormal];
self.kOneBtn.hidden = NO;
self.kTwoBtn.hidden = YES;
break;
}
case 2:
{
if (i==0) {
[self.kOneBtn addTarget:self action:@selector(showDeletePicAction:) forControlEvents:UIControlEventTouchUpInside];
[self.kOneBtn sd_setImageWithURL:[NSURL URLWithString:url] forState:UIControlStateNormal];
}else
//第二个Button
{
[self.kTwoBtn addTarget:self action:@selector(pressPicBtn:) forControlEvents:UIControlEventTouchUpInside];
[self.kTwoBtn sd_setImageWithURL:[NSURL URLWithString:url] forState:UIControlStateNormal];
}
self.kOneBtn.hidden = NO;
self.kTwoBtn.hidden = NO;
break;
}
default:
{ if (i==0) {
[self.kOneBtn addTarget:self action:@selector(showDeletePicAction:) forControlEvents:UIControlEventTouchUpInside];
[self.kOneBtn sd_setImageWithURL:[NSURL URLWithString:url] forState:UIControlStateNormal];
}else if(i==1){
[self.kTwoBtn addTarget:self action:@selector(showDeletePicAction:) forControlEvents:UIControlEventTouchUpInside];
[self.kTwoBtn sd_setImageWithURL:[NSURL URLWithString:url] forState:UIControlStateNormal];
}
self.kOneBtn.hidden = NO;
self.kTwoBtn.hidden = NO;
break;
}
}
}
}
for (int i = 0;i<aCount;i++) {
switch (i) {
case 1:
{
}
break;
default:
break;
}
}
if (![_info.cooperationState isEqualToString:@"TALKING"]) {
[self.kOneBtn removeTarget:self action:@selector(pressPicBtn:) forControlEvents:UIControlEventTouchUpInside];
[self.kTwoBtn removeTarget:self action:@selector(pressPicBtn:) forControlEvents:UIControlEventTouchUpInside];
}
}
-(IBAction)phoneCall:(id)sender
{
NSString *number = self.kphoneFiled.text;
BOOL res = [number checkPhoneNumInput];
if (!res) {
[self showToast:@"请输入合法手机号码" duration:3.0];
return;
}
NSString *callStr = [NSString stringWithFormat:@"tel://%@",number];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:callStr]];
}
@end
标签:
原文地址:http://www.cnblogs.com/guligei/p/4573719.html