0
HA ii,我在一个视图tableview和tab中有两个tableview,这个tab隐藏在mainview下面,用户只能在mainview中看到tableview,用户只需要点击按钮就可以看到button标签上面,当用户点击按钮就向上德雷奇到MAINVIEW我已经做到了这一点通过使用此代码TouchEvent在iphone中的疑问
-(IBAction) controlPanelShowHide:(id)sender
{
CGRect frame = tab.frame;
CGRect viewframe = hideviewoftab.frame;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.9];
if (!self.isExpanded)
{
self.isExpanded = YES;
if (frame.origin.y -=240) {
tab.frame = frame;
}
if (imageframe.origin.y -=240) {
btnShowHide.frame =imageframe;
}
if (viewframe.origin.y -=240) {
hideviewoftab.frame =viewframe;
}
} else {
self.isExpanded = NO;
if (frame.origin.y +=240) {
tab.frame = frame;
}
if (imageframe.origin.y +=240) {
btnShowHide.frame =imageframe;
}
if (viewframe.origin.y +=240) {
hideviewoftab.frame =viewframe;
}
}
[UIView commitAnimations];
}
每一个东西做工精细与此代码,但我需要用触摸事件拖动此选项卡,即当用户点击并按住它并在屏幕上拖动任何软件时(只向上)>我认为这是通过- (void) touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event
完成的。但我们怎么做到这一点?对于非常非常差的英语感到抱歉。希望您理解我的问题。 在此先感谢。 编辑:
- (void) touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event
{ CGPoint pt = [[touches anyObject] locationInView:self];
[tab beginAnimations:nil context:nil];
[tab setAnimationDuration:0.1];
CGRect newFrame = tab.frame;
newFrame.origin.y += pt.y - touchingPoint.y;
newFrame.origin.x += pt.x - touchingPoint.x;
[self setFrame:newFrame];
[tab commitAnimations];
}
- (void) touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event
{
CGPoint pt = [[touches anyObject] locationInView:self];
[tab beginAnimations:nil context:nil];
[tab setAnimationDuration:0.1];
CGRect newFrame = tab.frame;
newFrame.origin.y += pt.y - touchingPoint.y;
[self setFrame:newFrame];
[tab commitAnimations];
}
请看看我的编辑 – ICoder