当我触摸并按住图像2秒钟时,我正试图拨打警报框.这是我到目前为止所得到的:
- (void)viewDidLoad
{
[super viewDidLoad];
UILongPressGestureRecognizer *tapAndHoldGesture = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapAndHoldGesture:)];
tapAndHoldGesture.minimumPressDuration = 0.1;
tapAndHoldGesture.allowableMovement = 600;
[self.view addGestureRecognizer:tapAndHoldGesture];
}
- (void) handleTapAndHoldGesture:(UILongPressGestureRecognizer *)gestureRecognizer{
if (gestureRecognizer.state != UIGestureRecognizerStateEnded) {
return;
}
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Gesture:" message:@"hold it" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}
Run Code Online (Sandbox Code Playgroud)
不确定这是否会产生任何影响,但是Image View是以后以编程方式创建的,而不是在加载时.提前感谢您的任何帮助表示赞赏..
另外,我看了以下链接:
基本上,我有一个输入控制元素,您可以输入您拥有的苹果总数,并根据我想要设置的最大迷你苹果馅饼数量(您可以制作的每1个苹果1)迷你苹果派).Angularjs文档声明使用ngOptions,但我只想基于原始(苹果总数)而不是模型.
所以,如果我的totalApples值为2,那么我希望生成2个选项(其中一个值为1,另一个值为2)
我的代码到目前为止如下:
HTML片段:
<input ng-model="totalApples" />
<select ng-options="">
<option value="1">1</option> //what I would like to have is the options generated
<option value="2">2</option>
</select>
Run Code Online (Sandbox Code Playgroud)
在我的控制器中,我设置范围:
$scope.totalApples = 2;
Run Code Online (Sandbox Code Playgroud)
谢谢
使用 apache 日志(如下),我可以解析出一个 JSON:
[2014.02.14_21.24.22.543] other info I don't care about json: {
"petstore": "store_number_8",
"dogs":{
"terrier":{
"total":2
}
},
"cat":{
"siamese":{
"total":5
}
}
}
Run Code Online (Sandbox Code Playgroud)
1) 这是有效的 JSON 吗?2)为什么双引号会变成单引号?
读入后,解析出 JSON,并显示它,我得到以下信息:
{
'petstore': 'store_number_8',
'dogs':{
'terrier':{
'total':2
}
},
'cat':{
'siamese':{
'total':5
}
}
}
Run Code Online (Sandbox Code Playgroud)
顺便说一句,我正在使用 Node.js'fs.createStream读取日志,然后简单地执行控制台输出(到目前为止我没有进行任何清理,最终我会将其写入文件)。
fs.creatReadStream(logs).pipe(split()).on(data, function(line){
if(line.match(/json\:/)){
shouldThisBeValidJSON = JSON.parse(line.slice(line.indexOf('{'), line.length));
console.log(shouldThisBeValidJSON);
}
Run Code Online (Sandbox Code Playgroud)
先感谢您。