我正在添加一个这样的callout视图:
func mapView(mapView: MKMapView!,
didSelectAnnotationView view: MKAnnotationView!) {
let calloutView = UIView(frame:
CGRect(x: 0, y: 0, width: 300, height: 120))
calloutView.backgroundColor = UIColor.purpleColor()
calloutView.center = CGPointMake(CGRectGetWidth(view.bounds) / 2.0, 0.0)
calloutView.layer.anchorPoint = CGPointMake(0.5, 1.0)
calloutView.layer.masksToBounds = false
calloutView.userInteractionEnabled = true
let calloutViewTapRecognizer = UITapGestureRecognizer(target: self,
action: "onCalloutViewTap")
calloutView.addGestureRecognizer(calloutViewTapRecognizer)
view.addSubview(calloutView)
}
Run Code Online (Sandbox Code Playgroud)
虽然我的onCalloutViewTap函数从未被调用过......但我很想知道为什么以及能够处理与我的标注视图交互的东西.
我的应用程序在开发中工作得非常好,但切换到生产/ AdHoc版本它在转换到我的应用程序流程的第三个UIViewController时崩溃了.
在构建之间不应该有任何区别.我从"设备"窗口中检索了日志:
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x00000001000d49ac
Triggered by Thread: 0
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 MYAPP 0x00000001000d49ac 0x100010000 + 805292
1 UIKit 0x00000001868a8954 -[UIViewController loadViewIfRequired] + 688
2 UIKit 0x00000001868a8664 -[UIViewController view] + 28
3 UIKit 0x0000000186f9c1cc -[_UIFullscreenPresentationController _setPresentedViewController:] + 72
4 UIKit 0x0000000186ba378c -[UIPresentationController initWithPresentedViewController:presentingViewController:] + 116
5 UIKit 0x0000000186bbeb4c -[UIViewController _presentViewController:withAnimationController:completion:] + 1968
6 UIKit 0x0000000186bc0f64 __62-[UIViewController presentViewController:animated:completion:]_block_invoke + 116
7 UIKit 0x0000000186995c48 -[UIViewController presentViewController:animated:completion:] + 212
8 …Run Code Online (Sandbox Code Playgroud) Python中是否有任何方法可以反转通过"%"运算符完成的格式化操作?
formated = "%d ooo%s" % (12, "ps")
#formated is now '12 ooops'
(arg1, arg2) = theFunctionImSeeking("12 ooops", "%d ooo%s")
#arg1 is 12 and arg2 is "ps"
Run Code Online (Sandbox Code Playgroud)
编辑 Regexp可以解决这个问题,但是它们更难写,我怀疑它们更慢,因为它们可以处理更复杂的结构.我真的很喜欢sscanf.
我有一系列<circle>通过算法动态定位<svg>.我想在每个圆圈旁边添加一个图标,我正试图通过:
.node:after {
content:url(/img/icon.png);
}
Run Code Online (Sandbox Code Playgroud)
选择器是正确的,因为我在Firebug中看到它但没有图标显示.我想做一些不可能的事吗?为什么我不在某处看到我的图标?
额外的问题:是否可以将此图标相对于圆形元素的中心定位.
var t = [-12, 57, 22, 12, -120, -3];
t.map(Math.abs).reduce(function(current, previousResult) {
return Math.min(current, previousResult);
}); // returns 3
t.map(Math.abs).reduce(Math.min); // returns NaN
Run Code Online (Sandbox Code Playgroud)
我不明白为什么第二种形式不起作用.欢迎任何解释.
编辑:技术背景:Chrome和Firefox JavaScript引擎.见ES5减少http://www.ecma-international.org/ecma-262/5.1/#sec-15.4.4.21
我正在尝试测试Scrapy爬行网页,我不明白为什么我的抓取工具只抓取一个页面,我试图评论规则和allowed_domains没有成功.我想有一些愚蠢的东西,我错过任何帮助都会感激.
from scrapy.contrib.spiders import CrawlSpider, Rule
from scrapy.spider import BaseSpider
from scrapy.contrib.linkextractors.sgml import SgmlLinkExtractor
class NYSpider(CrawlSpider):
name = "ny"
allowed_domains = ["nytimes.com"]
start_urls = ["http://www.nytimes.com/"]
rules = (
Rule(SgmlLinkExtractor(allow=('/2012', )), callback='parse_article'),
Rule(SgmlLinkExtractor(allow=('/page', ))),
)
def parse(self, response):
print 'page '+response.url
def parse_article(self, response):
print 'article '+response.url
Run Code Online (Sandbox Code Playgroud)
任何对整个站点进行爬行的程序样本也会受到欢迎.
编辑2:因为很多人都在反对这个用例可以揭示的糟糕设计.这些问题和答案的读者在使用之前应该三思而后行
我试图在Python中用它的名字设置一个变量(不是属性):
foo = 'bar'
thefunctionimlookingfor('foo', 'baz')
print foot #should print baz
Run Code Online (Sandbox Code Playgroud)
PS:通过名称(没有eval)访问变量的函数将是一个加号!
编辑:我知道字典存在,这种用法是不鼓励的,我选择将它用于一个非常特定的目的(根据环境配置文件修改),这将让我的代码更容易阅读.
我的应用程序正在使用Facebook让用户登录.它在从XCode进行调试并通过AdHoc部署进行测试时工作正常,为了让外部测试人员提交我们的应用程序进行审核,但似乎Facebook在OAuth流程期间抱怨"App Not安装程序:此应用程序的开发人员尚未正确设置此应用程序进行Facebook登录".
在FacebookDisplayName与FacebookAppId存在于Custom iOS target properties在info我的目标的XCode中节相匹配的Facebook应用程序的开发版本.不知何故,SDK必须检测到在审核期间应用程序不再处于开发状态并且发生错误.
如何在该目标中定义一些Custom iOS target properties具有不同release和debug值的?
我已经完成了Zend 2的教程,感觉Zend\Db组件有点失望.实际上,它无法处理外键(作为内置).
如何为现实世界的项目(至少十个不同的表和关系)解决这个问题?
我是否应该考虑尝试或多或少地重写Zend_Db(ZF1)的findDependentRowset或findParentRow?我错了,如果我认为这是不可能的,因为它会打破PHP对象的教条,不知道用Data Mapper模式销售的外部世界.
我是否应该始终认为使用外键/关系的代码在表示实体的对象中无关?这可能最终成为一个美丽的意大利面条代码.
我应该放弃Zend\Db for Doctrine还是Propel?
r = {}
r[0] = [1, 2]
r[2] = [1, 2, 4]
r[4] = [1, 2, 5]
r[6] = [1, 2]
count = 0
r.each do |x|
count += x.length
end
puts count #output is 8 expected value is 10
Run Code Online (Sandbox Code Playgroud)