cool,
#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++) {
UIImage *image = [self.roomImgArray objectAtIndex:i];
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;
}
}
}
}