I have this code for increase height of a image.
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch *touch = [[event allTouches] anyObject];
touchStart = [[touches anyObject] locationInView:self.image];
touchStart2 = [[touches anyObject] locationInView:self.tableView];
isResizingLR = ( self.image.bounds.size.height - touchStart.y < kResizeThumbSize );
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
CGPoint touchPoint = [[touches anyObject] locationInView:self.image];
CGPoint previous=[[touches anyObject]previousLocationInView:self.image];
float deltaWidth = touchPoint.x-previous.x;
float deltaHeight = touchPoint.y-previous.y;
if (isResizingLR) {
self.image.frame = CGRectMake(self.image.frame.origin.x, self.image.frame.origin.y, self.image.frame.size.width, touchPoint.y + deltaWidth);
self.tableView.frame = CGRectMake(self.tableView.frame.origin.x ,self.tableView.frame.origin.y + deltaHeight, self.tableView.frame.size.width, self.tableView.frame.size.height - deltaHeight );
self.viewTitle.frame = CGRectMake(self.viewTitle.frame.origin.x ,self.viewTitle.frame.origin.y + deltaHeight, self.viewTitle.frame.size.width, self.viewTitle.frame.size.height);
}
}
I want put a condition for a minimHeight =100 and maximHeight =300; How can i do that? I already try this :
if (isResizingLR) {
if (self.image.frame.size.height >100 && self.image.frame.size.height <300) {
self.image.frame = CGRectMake(self.image.frame.origin.x, self.image.frame.origin.y, self.image.frame.size.width, touchPoint.y + deltaWidth);
self.tableView.frame = CGRectMake(self.tableView.frame.origin.x ,self.tableView.frame.origin.y + deltaHeight, self.tableView.frame.size.width, self.tableView.frame.size.height - deltaHeight );
self.viewTitle.frame = CGRectMake(self.viewTitle.frame.origin.x ,self.viewTitle.frame.origin.y + deltaHeight, self.viewTitle.frame.size.width, self.viewTitle.frame.size.height);
}
}
but every time after dragged image at: self.image.frame.size.height =100 or 300, i can't resize image. He need to be draggable all time! Thank you!
EDIT: I don't want resize image when heightImage is 100.
My original height of image is 200. My user can click and resize image how he want, but no over 300 and less than 100. I just put a minimum and maximum height. I hope you understand now.
I solved the problem.
int aux=touchPoint.y + deltaWidth;
if (aux>300) {
aux=300;
}
else if(aux<100){
aux=100;
}
self.image.frame = CGRectMake(self.image.frame.origin.x, self.image.frame.origin.y, self.image.frame.size.width, aux);