我有一个实例,MKMapView并希望使用自定义注释图标,而不是MKPinAnnotationView提供的标准图钉图标.所以,我已经设置了一个名为CustomMapAnnotation的MKAnnotationView的子类,并且重写-(void)drawRect:了绘制CGImage.这有效.
当我尝试复制.animatesDropMKPinAnnotationView提供的功能时出现问题; 当注释被添加到MKMapView实例时,我希望我的图标能够逐渐显示,从上到下以及从左到右顺序显示.
这是 - (void)drawRect:用于CustomMapAnnotation,当你只绘制UIImage(这是第二行所做的)时它可以工作:
- (void)drawRect:(CGRect)rect {
[super drawRect:rect];
[((Incident *)self.annotation).smallIcon drawInRect:rect];
if (newAnnotation) {
[self animateDrop];
newAnnotation = NO;
}
}
Run Code Online (Sandbox Code Playgroud)
添加animateDrop方法时出现问题:
-(void)animateDrop {
CGContextRef myContext = UIGraphicsGetCurrentContext();
CGPoint finalPos = self.center;
CGPoint startPos = CGPointMake(self.center.x, self.center.y-480.0);
self.layer.position = startPos;
CABasicAnimation *theAnimation;
theAnimation=[CABasicAnimation animationWithKeyPath:@"position"];
theAnimation.fromValue=[NSValue valueWithCGPoint:startPos];
theAnimation.toValue=[NSValue valueWithCGPoint:finalPos];
theAnimation.removedOnCompletion = NO;
theAnimation.fillMode = kCAFillModeForwards;
theAnimation.delegate = self;
theAnimation.beginTime = 5.0 * (self.center.x/320.0);
theAnimation.duration = 1.0;
[self.layer addAnimation:theAnimation …Run Code Online (Sandbox Code Playgroud) 这个问题太奇怪了.
我使用jquery将特定的id链接到一个警报("你好").
$("#submit_reply").live("click", function() {
event.preventDefault();
alert("hellooooo");
});
Run Code Online (Sandbox Code Playgroud)
现在在safari中,当我点击它工作.但是当我使用firefox它不工作.submit_reply(提交按钮)刷新整个页面.也就是说,jquery无法绑定它.
我该如何调试这个问题?firefox在控制台中显示没有错.但为什么它在野生动物园中起作用?我可以使用什么工具来检查问题是什么......帮助!
我需要做点什么
{{ article.product.images.first.image.url }}
Run Code Online (Sandbox Code Playgroud)
在我的模板,但没有"第一"(images是RelatedManager的,我发现很少的文档).
还有另一种方法吗?我可以得到第一个模型
{{ article.product.images.get_query_set|first }}
Run Code Online (Sandbox Code Playgroud)
但后来我需要深入挖掘一些属性,但这不起作用.
如果有帮助,我的图像模型如下所示:
class ComponentImage(models.Model):
component = models.ForeignKey(Component, related_name='images')
image = models.ImageField(upload_to='uploads')
Run Code Online (Sandbox Code Playgroud)
而且article.product是一个Component.
我在一个数组上有一个jQuery for-each循环,并想知道是否有可能提前离开循环.
$(lines).each(function(i){
// some code
if(condition){
// I need something like break;
}
});
break; 实际上是行不通的.
如果我写一个for循环它会看起来像那样(但我不想那样):
for(i=0; i < lines.length; i++){
// some code
if(condition){
break; // leave the loop
}
};
在此先感谢-Martin
我是新手,如果这很容易就很抱歉.我想知道上传图片并在Ruby on Rails中显示它们的最佳方法.我有一个博客,并希望在创建帖子时可以选择附加图片.
我希望能够在以下场景中检测鼠标是否仍然在元素上:
我怎样才能达到#2?
谢谢.
首先请让我说我对客观的c开发很新.我正在为iphone编写一个供个人使用的小应用程序,但是在执行以下代码时遇到了一些问题:
NSString *sql = [[NSString alloc] initWithFormat:@"select color_r, color_g, color_b from Calendar where ROWID = %@", [calendarsID objectForKey:[arrayColors objectAtIndex:row]]];
sqlite3_stmt *selectstmt;
if(sqlite3_prepare_v2(database, sql, -1, &selectstmt, NULL) == SQLITE_OK)
Run Code Online (Sandbox Code Playgroud)
编译器告诉我,我从不兼容的指针类型传递sqlite3_prepare_v2的参数2.无论如何,程序会被编译并运行,但是当它必须执行我刚刚向您显示的代码时,它会产生错误.它表示查询中存在语法错误,语法错误仅在查询的最后部分.而不是:
从Calendar中选择color_,color_g,color_b,其中ROWID = 63(例如)
我在最后一个数字的位置得到了奇怪的字符(63).我想这是一个与字符串转换有关的问题.可以请任何人帮帮我吗?
非常感谢您的关注.阿莱西奥
我有一个Java应用程序要部署,并希望与它一起部署JVM(以简化安装).我希望将JVM剥离为仅包含应用程序需要保持可分发的小块.如何拆除JVM以降低尺寸?这可以通过Java内核完成,还是可以替代安装小得多的Sun JVM?我的目标平台是Windows.
NP,NP-Complete和NP-Hard有什么区别?
我知道网上有很多资源.我想阅读你的解释,原因是它们可能与那些不同,或者有些东西我不知道.
我想用xmllitein 编写一个简单的xml文件win32 c++.每次用户保存时都会保存文件.我该怎么做呢?我宁愿不为此包含任何新库...
jquery ×3
blogs ×1
c++ ×1
cocoa ×1
django ×1
dom ×1
each ×1
events ×1
file-upload ×1
hover ×1
installation ×1
iphone ×1
java ×1
javascript ×1
jvm ×1
mapkit ×1
mouseover ×1
np ×1
np-complete ×1
np-hard ×1
nsstring ×1
objective-c ×1
ruby ×1
sqlite ×1
templatetags ×1
winapi ×1
xml ×1