- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在开发一个应用程序,我必须在其中从 UIScrollview 拖动 UIImageview。在我的主 UIView 的底部,我有一个 UIScrollView,里面有 UIImageViews。我使用以下代码片段创建了自定义 UIScrollview:
@interface CustomScroll : UIScrollView {
}@end
@implementation CustomScroll
- (id)initWithFrame:(CGRect)frame {
return [super initWithFrame:frame];
}
- (void) touchesMoved: (NSSet *) touches withEvent: (UIEvent *) event {
// If not dragging, send event to next responder
if (!self.dragging) {
self.scrollEnabled=NO;
[self.nextResponder touchesMoved:touches withEvent:event];
}
else{
[super touchesMoved: touches withEvent: event];
}
- (void) touchesEnded: (NSSet *) touches withEvent: (UIEvent *) event {
// If not dragging, send event to next responder
if (!self.dragging)
[self.nextResponder touchesEnded: touches withEvent:event];
else
[super touchesEnded: touches withEvent: event];
}
@end
从这里开始,我在我的 PuzzleViewController 中包含了一个 CustomScroll 对象,并将它连接到 Interface builder 的 ScrollView :
@interface PuzzleViewController : UIViewController <UIScrollViewDelegate> {
IBOutlet CustomScroll *segmentScrollview;
我已经以编程方式添加了所有 UIImageviews。
此代码按预期工作。 UIImageview 检测触摸,我可以将 UIImageview 从 UIScrollview 拖到 UIView。
但是当我对角拖动 UIImageview 时出现问题。
在我的应用程序中,当我从 ScrollView 垂直拖动 UIImageview 时,我能够将我的 UIImageView 从 UIScrollView 移动到 UIView。但是当我从 scrollview 沿对角线拖动 UIImageview 时,我无法移动 UIImageview。对角滑动滚动 UIScrollview [UIImageview 保持不变] 这是意外的。我希望 UIImageview 应该从 UIScrollview 沿对角线拖动。
如有任何帮助,我们将不胜感激。
在此先感谢您的帮助。
最佳答案
这只是一个想法...所以请尝试一下,然后告诉我进展如何。如果不起作用,那么我会尝试进一步帮助您。尝试设置 directionalLockEnabled
否。如果设置为 YES,那么您的移动将仅限于水平/垂直。如果它设置为 NO 那么你应该能够沿对角线移动。试试看,让我知道结果如何。
UIScrollView directionLockEnabled Docs
If this property is NO, scrolling is permitted in both horizontal and vertical directions. If this property is YES and the user begins dragging in one general direction (horizontally or vertically), the scroll view disables scrolling in the other direction. If the drag direction is diagonal, then scrolling will not be locked and the user can drag in any direction until the drag completes. The default value is NO
关于iphone- UIScrollview 对角滑动意外行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7994902/
我真的不知道这个问题以前是否有人问过(我真的找不到) 所以,我正在学习如何创建基本的颜色切换游戏(随机颜色球下降,你需要旋转轮子与相同颜色的球碰撞) 通过这种轮换,我遇到了一个非常大的问题。我需要以某
我必须找到具有 M 对角线和 M << N 的对称方 NxN 矩阵的行列式.有没有比LU分解矩阵更快的方法? 最佳答案 是的,带(ed)矩阵有特殊的方法可以解决复杂度为 O(N*M^2) 的消元问题。
我有一个列数和行数相等的二维 numpy 数组。我想将它们排列成一个更大的阵列,对角线上有较小的阵列。应该可以指定起始矩阵在对角线上的频率。例如: a = numpy.array([[5, 7],
我是一名优秀的程序员,十分优秀!