我是手势识别器的新手所以也许这个问题听起来很愚蠢:我正在为一堆UIViews分配轻拍手势识别器.在该方法中,有可能找出以某种方式点击它们中的哪一个,或者我是否需要使用点击屏幕上的点找到它?
for (NSUInteger i=0; i<42; i++) {
float xMultiplier=(i)%6;
float yMultiplier= (i)/6;
float xPos=xMultiplier*imageWidth;
float yPos=1+UA_TOP_WHITE+UA_TOP_BAR_HEIGHT+yMultiplier*imageHeight;
UIView *greyRect=[[UIView alloc]initWithFrame:CGRectMake(xPos, yPos, imageWidth, imageHeight)];
[greyRect setBackgroundColor:UA_NAV_CTRL_COLOR];
greyRect.layer.borderColor=[UA_NAV_BAR_COLOR CGColor];
greyRect.layer.borderWidth=1.0f;
greyRect.userInteractionEnabled=YES;
[greyGridArray addObject:greyRect];
[self.view addSubview:greyRect];
NSLog(@"greyGrid: %i: %@", i, greyRect);
//make them touchable
UITapGestureRecognizer *letterTapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(highlightLetter)];
letterTapRecognizer.numberOfTapsRequired = 1;
[greyRect addGestureRecognizer:letterTapRecognizer];
}
Run Code Online (Sandbox Code Playgroud) 在较旧版本的Jade中,我能够包含部分并将变量传递到它们中:!= partial('partials/video',{title:video.title,artist:video.artist})现在部分内涵不会再也存在了.如何使用include内涵实现相同的功能?
我正在研究用于学习d3的个人财务的可视化,其中有些东西感觉像是一个有用的项目.我已经设法按照我想要的方式制作图表(每日+或减去).现在我希望能够从一个月改为下一个月.如果旧月(更新前)有更多天(也称为数据点)而不是新月(更新后),则此方法有效.如果旧数据点的数据点少于新数据点,则会在图表顶部添加其他数据点.我将条形图中的每个数据点添加为一个组(条形本身,数据标签+日期标签).我正在为每个新的一天向下翻译整个小组.我需要弄清楚的是,如果在更新后我有更多或更少的数据点,如果我有更少,我需要向下翻译新的数据点.你知道我的意思?这是我最初添加条形图的代码:
bar = chart.selectAll("g")
.data(data)
.enter().append("g")
.attr("transform", function(d, i) { return "translate(0," + i * barHeight + ")"; });
//bar
//grey background bars
bar.append("rect")
.attr("class", "backgroundBar")
.attr("x", 10)
.attr("width", (width-30))
.attr("height", barHeight-1)
.attr("fill", "#dddddd")
.attr("fill-opacity", "0.3");
//dateLabel
bar.append("text")
.attr("class", "dateLabel")
.attr("x", width/2-20)
.attr("y", barHeight-5)
.attr("fill", "black")
.text(function(d){ return d.key})
bar.append("rect")
.attr("class", "bar")
.attr("x", function(d) { if(scale(d.values.total)<0){return width/2+widthDateLabel;}else{return width/2-scale(d.values.total)-widthDateLabel;}})
.attr("width", function(d) { return Math.abs(scale(d.values.total)); })
.attr("height", barHeight - 1)
.attr("fill", function(d) { if(scale(d.values.total)<0){ return "DeepPink"}else{return "MediumSeaGreen"}});
//BarLabel
bar.append("text")
.attr("class", "barLabel")
.attr("x",function(d) …Run Code Online (Sandbox Code Playgroud) 这应该是相当容易的,可能我只是遗漏了一件小事:我有一个名为defaultImages的图像数组
NSMutableArray *defaultLetters;
Run Code Online (Sandbox Code Playgroud)
然后我添加所需的字母(数组长度然后是42)
后来我试图用另一个图像替换阵列中的一个图像.像这样:
[defaultLetters replaceObjectAtIndex:0 withObject:croppedPhoto];
Run Code Online (Sandbox Code Playgroud)
但我得到一个错误说:" - [__ NSArrayI replaceObjectAtIndex:withObject:]:无法识别的选择器发送到实例0x180ae190"是否有一个我缺少的步骤?