其实我有一个滚动视图。我正在使用30个按钮。我的要求是什么我需要重新排列按钮。就像,当我触摸任何按钮,它应该与我们的触摸选择。我们在滚动视图中移动的位置应该随着触摸移动。在我结束触摸之后,按钮应该交换。任何人都可以帮我解决这个问题.........我们不能使用touchesBegan,touchesMoved,touchesEnded进行scrollview吗?
0
A
回答
0
你可以做到这一点,但是还有很多工作要做。你需要下一个:
1.创建UIControl子类,它将成为你的按钮。
2.覆盖所有触摸*方法。
3.实现标准uicontrol行为+移动行为的支持。
#pragma mark -
#pragma mark Touches delegate methods
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
[self performSelector:@selector(delayedTouchBeging:) withObject:touch afterDelay:0.15];
[super touchesBegan:touches withEvent:event];
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
if (dragging) {
// move your view in new position here
} else {
[super touchesMoved:touches withEvent:event];
}
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
if (dragging) {
// Do other stuff if you need
} else {
[super touchesEnded:touches withEvent:event];
}
dragging = NO;
[NSObject cancelPreviousPerformRequestsWithTarget:self];
}
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
[self touchesEnded:touches withEvent:event];
}
- (void) delayedTouchBeging:(UITouch*) touch {
dragging = YES;
[self cancelTrackingWithEvent:nil];
// Do here stuff about begin moving (animation, etc)
}
0
您可能想了解他们如何将“启动器”代码作为免费提供的three20代码目录的一部分。他们做的是这样的事情(并模仿iPhone应用程序视图,您可以在其中移动应用程序或删除它们)。
相关问题
- 1. touchesbegan,touchesmoved,touchesended问题
- 2. UIGestureRecognizers与touchesBegan/touchesMoved/touchesEnded(准确性)
- 3. 的touchesBegan和touchesMoved卡
- 4. touchesMoved调用没有touchesBegan
- 5. iPhone:泛移动使用touchesBegan,touchesMoved和touchesEnd
- 6. Touchesbegan使用touchesmoved时总是会触发?
- 7. TouchesEnded检测到,但不是的touchesBegan
- 8. 如何区分touchesBegan和touchesMoved
- 9. TouchesBegan和TouchesEnded与多点触发问题
- 10. touchesBegan和touchesEnded之间有一个方法吗?
- 11. 禁用scrollview如此touchesMoved可以工作?
- 12. Obj-C,iOS,我如何编写/使用包含touchesBegan和touchesMoved等的标准类?
- 13. 有没有什么时候touchesBegan,touchesMoved和touchesEnded方法会在UIViewController和UIView内处理?
- 14. 我们可以在LinearLayout中使用ScrollView吗?
- 15. ScrollView与图像 - 改变touchesended选项卡不起作用
- 16. iPhone“touchesBegan”和“touchesMoved”消息...不要移动到触摸中心
- 17. 为什么UIEvent在touchesBegan和touchesMoved中有不同的对象?
- 18. iPhone多点触控 - 一些触摸调度touchesBegan:但不touchesMoved:
- 19. 如何通过编程调用TouchesBegan,TouchesMoved,TouchedEnded
- 20. 我们可以使用javascript连接数据库进行功能测试吗?
- 21. 我们可以使用JSch进行SSH密钥通信吗?
- 22. 我们可以使用MongoDB进行临时存储吗?
- 23. 我们可以使用工会进行类型转换吗?
- 24. 我们应该使用JQuery进行Mobile AJAX页面导航吗?
- 25. touchesBegan和touchesEnded在另一个子视图上检测到
- 26. CADisplayLink导致touchesBegan和touchesEnded之间的延迟?
- 27. 我们怎样才能进行使用InternJS
- 28. 我们可以使用EventObject在不同的JVM之间进行通信吗?
- 29. 我们不能在HashSet中使用StringComparison吗?
- 30. 是否可以从touchesBegan或touchesMoved内部取消触摸?
你的要求是什么部分你有问题? – Vladimir 2010-04-26 12:59:29