我一直在阅读很多关于SO的手势识别器 - 并且设法编写了一个工作代码,当在UIImage上识别出长按时,会出现一个操作表:
{ ...
UILongPressGestureRecognizer *longPressWall = [[[UILongPressGestureRecognizer alloc]
initWithTarget:self action:@selector(deleteImage:)] autorelease];
longPressWall.minimumPressDuration = 0.4;
l.userInteractionEnabled=YES;
[l addGestureRecognizer:longPressWall];
... }
-(void)deleteImage:(UILongPressGestureRecognizer*)sender {
if(UIGestureRecognizerStateBegan == sender.state) {
UIActionSheet *as = [[UIActionSheet alloc] initWithTitle:@"" delegate:self cancelButtonTitle:@"Close" destructiveButtonTitle:@"Delete Screenshot" otherButtonTitles: nil];
[as showInView:masterView];
[as release];
}
}
Run Code Online (Sandbox Code Playgroud)
因此,deleteImage:在这种情况下,向Selector发送信息有点棘手.我想在调用deleteImage时向服务器发送HTTP请求,因此我需要从视图中获取一些信息.
反正是否存储信息UIImageView并从中检索sender.view.myinfo(例如)?
谢谢!
我想将一个char数组哈希到一个int或long.结果值必须符合给定的精度值.我一直在使用的功能如下:
int GetHash(const char* zKey, int iPrecision /*= 6*/)
{
/////FROM : http://courses.cs.vt.edu/~cs2604/spring02/Projects/4/elfhash.cpp
unsigned long h = 0;
long M = pow(10, iPrecision);
while(*zKey)
{
h = (h << 4) + *zKey++;
unsigned long g = h & 0xF0000000L;
if (g) h ^= g >> 24;
h &= ~g;
}
return (int) (h % M);
}
Run Code Online (Sandbox Code Playgroud)
要哈希的字符串类似于"SAEUI1210.00000010_1".
但是,在某些情况下,这会产生重复值.是否有任何好的替代方案不会为不同的字符串值复制相同的哈希值.