Hi Guy's
I need a help from your side.Actually I am having a Custom button say(button1) to which I am adding an image and another custom button deleteButton as a subviews.There is button action for button1 and deleteButton.My problrm is I had an edit button.by default I am not showing the delete button when I click the edit button then only delete button is shown.My need is when I click the button1 the action for it should not b performed and when i click on to the delete button its action should only perform.
My code I written was:
-(void)loadImagesForPage:(UIView*) view
{
for (UIView* subview in scrollView.subviews)
{
[subview removeFromSuperview];
}
int currentRow = 0;
int currentColumn = 0;
int val1;
float v = [favoritesArray count];
float val = v/numberOfColumns;
if(val > 1 || val > 0.3)
{
val1 = [favoritesArray count]/numberOfColumns+1;
}
else
{
val1 = [favoritesArray count]/numberOfColumns;
}
int scrollViewHeight = (([favoritesArray count])/(numberOfColumns))+1;
if (val1 > 3)
{
scrollView.contentSize = CGSizeMake(320, 130*scrollViewHeight);
}
else
{
scrollView.contentSize = CGSizeMake(320, 440);
}
for(currentRow = 0; currentRow < val1 ; currentRow++)
{
for (currentColumn = 0 ; currentColumn < numberOfColumns; currentColumn++)
{
indexValue = currentRow * 3 + currentColumn;
if(indexValue < [favoritesArray count])
{
ContactDTO* dtoObject = [favoritesArray objectAtIndex:indexValue];
CGRect viewRect = CGRectMake(currentColumn * 105 + 5, currentRow * 130 + 5, 100, 124);
firstColumnButton = [[MyCustomButton alloc] initWithObjectValue:dtoObject];
firstColumnButton.clipsToBounds = YES;
firstColumnButton.contentMode = UIViewContentModeScaleToFill;
[firstColumnButton setImage:[UIImage imageNamed:@"Bgwhite.png"] forState:UIControlStateNormal];
[firstColumnButton addTarget:self action:@selector(callbtnAction:) forControlEvents:UIControlEventTouchUpInside];
[firstColumnButton setFrame:viewRect];
[scrollView addSubview:firstColumnButton];
NSData* imageData = [self getContactDTOForId:dtoObject.contactId];
printf("\n imadata Length %d",[imageData length]);
imageViewL = [[UIImageView alloc] initWithFrame:CGRectMake(7, 10, 85, 80)];
if ([imageData length] > 0)
{
int len = [imageData length];
if(len > 9000)
{
UIImage *theImage = [UIImage imageWithData:imageData];
imageViewL.image = [self scaleImage:theImage toSize:CGSizeMake(150.0,150.0)];
}
else
{
imageViewL.image = [UIImage imageWithData:imageData];
}
}
else
{
imageViewL.image = [UIImage imageNamed:@"defaultitemimage.png"];
}
[firstColumnButton addSubview:imageViewL];
if(isEdit == YES)
{
[self doWiggle:firstColumnButton];
CGRect viewRect1 = CGRectMake(2 ,2, 25, 25);
MyCustomButton* delButton = [[MyCustomButton alloc] initWithObjectValue:dtoObject];
delButton.clipsToBounds = YES;
delButton.contentMode = UIViewContentModeScaleToFill;
[delButton setImage:[UIImage imageNamed:@"cancel_1.png"] forState:UIControlStateNormal];
[delButton addTarget:self action:@selector(deleteBtnAction:) forControlEvents:UIControlEventTouchUpInside];
[delButton setFrame:viewRect1];
[firstColumnButton addSubview:delButton];
[delButton release];
}
[imageViewL release];
UILabel* contactName = [[UILabel alloc] initWithFrame:CGRectMake(10,90,85,30)];
NSString* str = @" ";
if ([dtoObject.firstName length] > 0 && [dtoObject.firstName length] > 0)
{
contactName.text = [dtoObject.firstName stringByAppendingFormat:@"%s%s",[str UTF8String],[dtoObject.lastName UTF8String]];
}
else if([dtoObject.firstName length] == 0)
{
contactName.text = dtoObject.lastName;
}
else if([dtoObject.lastName length] == 0)
{
contactName.text = dtoObject.firstName;
}
contactName.font = [UIFont systemFontOfSize:10];
contactName.backgroundColor = [UIColor clearColor];
contactName.textAlignment = UITextAlignmentCenter;
[firstColumnButton addSubview:contactName];
[contactName release];
[firstColumnButton release];
}
}
}
[mView addSubview:scrollView];
}
Guy's please suggest me how to go with this.
Anyone's help will be much appreciated.
Thanks to all, Monish.