有没有人遇到过这个错误(见下文)。当我在 MKMapView 中拖动一个图钉然后放下它时会发生这种情况......当放下应用程序崩溃时。我的 MKAnnotation 实现也有坐标的 getter/setter!!!?
System.Exception: Failed to find selector _original_setCoordinate: on DivineiPhone.FoundAnnotation
at MonoTouch.ObjCRuntime.Runtime.GetMethod (IntPtr klass, IntPtr selptr) [0x0001c] in /Users/plasma/Source/iphone/monotouch/ObjCRuntime/Runtime.cs:127
at (wrapper native-to-managed) MonoTouch.ObjCRuntime.Runtime:GetMethod (intptr,intptr)
at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/plasma/Source/iphone/monotouch/UIKit/UIApplication.cs:26
at DivineiPhone.Application.Main (System.String[] args) [0x00000] in /Users/stevepthornton/Projects/DivineiPhone/DivineiPhone/Classes/Main.cs:15
感谢您的帮助...我不知道发生了什么:(
史蒂夫
这是我的代码...
public class FoundAnnotation : MKAnnotation
{
private CLLocationCoordinate2D coordinate;
private string _title, _subtitle;
private bool _clickThru;
private string _desc;
public override CLLocationCoordinate2D Coordinate
{
set { coordinate = value; }
get { return coordinate; }
}
public override string Title
{
get { return _title; }
}
public override string Subtitle
{
get { return _subtitle; }
}
public bool ClickThru
{
get { return _clickThru; }
set { _clickThru = value; }
}
public string Description
{
get { return _desc; }
set { _desc = value; }
}
public FoundAnnotation (CLLocationCoordinate2D coord, string t, string s, bool click, string description) : base()
{
coordinate=coord;
_title=t;
_subtitle=s;
_clickThru = click;
_desc = description;
}
}
public override MKAnnotationView GetViewForAnnotation (MKMapView mapView, NSObject annotation)
{
try
{
if (annotation is MKUserLocation)
{
return null; //default to blue dot
}
else if (annotation is FoundAnnotation)
{
MKPinAnnotationView pinanv = new MKPinAnnotationView(annotation, "thislocation");
pinanv.AnimatesDrop = true;
pinanv.PinColor = MKPinAnnotationColor.Green;
FoundAnnotation customAnnotation = (FoundAnnotation)annotation;
pinanv.CanShowCallout = true;
UIButton rightCallout = UIButton.FromType(UIButtonType.ContactAdd);
rightCallout.Frame = new System.Drawing.RectangleF(250, 8f, 25f, 25f);
rightCallout.TouchDown += delegate {
addStore = new AddStoreViewController(this, customAnnotation, mapView);
_svc.NavigationController.PushViewController(addStore, true);
};
pinanv.RightCalloutAccessoryView = rightCallout;
pinanv.Draggable = true;
return pinanv;
}
else if (annotation is StoreAnnotation)
{
MKPinAnnotationView pinanv = new MKPinAnnotationView(annotation, "thislocation");
pinanv.AnimatesDrop = true;
pinanv.Image = UIImage.FromFile("Images/MapPin.png");
pinanv.CanShowCallout = true;
return pinanv;
}
return null;
}
catch (Exception ex)
{
return null;
}
}
最佳答案
这在 MonoTouch 5.2.5 上仍然发生。如前所述,以下代码修复了它:
public override CLLocationCoordinate2D Coordinate
{
get
{
return this.coordinate;
}
set
{
this.SetCoordinate(value);
}
}
[Export("_original_setCoordinate:")]
public void SetCoordinate(CLLocationCoordinate2D coord)
{
this.WillChangeValue("coordinate");
this.coordinate = coord;
this.DidChangeValue("coordinate");
}
关于c# - MKMapView - 可拖动引脚导致放置错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4878743/
大约一年前,我决定确保每个包含非唯一文本的Flash通知都将从模块中的方法中获取文本。我这样做的最初原因是为了避免一遍又一遍地输入相同的字符串。如果我想更改措辞,我可以在一个地方轻松完成,而且一遍又一遍地重复同一件事而出现拼写错误的可能性也会降低。我最终得到的是这样的:moduleMessagesdefformat_error_messages(errors)errors.map{|attribute,message|"Error:#{attribute.to_s.titleize}#{message}."}enddeferror_message_could_not_find(obje
我遵循MichaelHartl的“RubyonRails教程:学习Web开发”,并创建了检查用户名和电子邮件长度有效性的测试(名称最多50个字符,电子邮件最多255个字符)。test/helpers/application_helper_test.rb的内容是:require'test_helper'classApplicationHelperTest在运行bundleexecraketest时,所有测试都通过了,但我看到以下消息在最后被标记为错误:ERROR["test_full_title_helper",ApplicationHelperTest,1.820016791]test
我有一张背景图片,我想在其中添加一个文本框。我想弄清楚如何将标题放置在其顶部的正确位置。(我使用标题是因为我需要自动换行功能)。现在,我只能让文本显示在左上角,但我需要能够手动定位它的开始位置。require'RMagick'require'Pry'includeMagicktext="Loremipsumdolorsitamet"img=ImageList.new('template001.jpg')img 最佳答案 这是使用convert的ImageMagick命令行的答案。如果你想在Rmagick中使用这个方法,你必须自己移植
我是rails的新手,想在form字段上应用验证。myviewsnew.html.erb.....模拟.rbclassSimulation{:in=>1..25,:message=>'Therowmustbebetween1and25'}end模拟Controller.rbclassSimulationsController我想检查模型类中row字段的整数范围,如果不在范围内则返回错误信息。我可以检查上面代码的范围,但无法返回错误消息提前致谢 最佳答案 关键是您使用的是模型表单,一种显示ActiveRecord模型实例属性的表单。c
我正在尝试编写一个将文件上传到AWS并公开该文件的Ruby脚本。我做了以下事情:s3=Aws::S3::Resource.new(credentials:Aws::Credentials.new(KEY,SECRET),region:'us-west-2')obj=s3.bucket('stg-db').object('key')obj.upload_file(filename)这似乎工作正常,除了该文件不是公开可用的,而且我无法获得它的公共(public)URL。但是当我登录到S3时,我可以正常查看我的文件。为了使其公开可用,我将最后一行更改为obj.upload_file(file
我克隆了一个rails仓库,我现在正尝试捆绑安装背景:OSXElCapitanruby2.2.3p173(2015-08-18修订版51636)[x86_64-darwin15]rails-v在您的Gemfile中列出的或native可用的任何gem源中找不到gem'pg(>=0)ruby'。运行bundleinstall以安装缺少的gem。bundleinstallFetchinggemmetadatafromhttps://rubygems.org/............Fetchingversionmetadatafromhttps://rubygems.org/...Fe
在Cooper的书BeginningRuby中,第166页有一个我无法重现的示例。classSongincludeComparableattr_accessor:lengthdef(other)@lengthother.lengthenddefinitialize(song_name,length)@song_name=song_name@length=lengthendenda=Song.new('Rockaroundtheclock',143)b=Song.new('BohemianRhapsody',544)c=Song.new('MinuteWaltz',60)a.betwee
我是Google云的新手,我正在尝试对其进行首次部署。我的第一个部署是RubyonRails项目。我基本上是在关注thisguideinthegoogleclouddocumentation.唯一的区别是我使用的是我自己的项目,而不是他们提供的“helloworld”项目。这是我的app.yaml文件runtime:customvm:trueentrypoint:bundleexecrackup-p8080-Eproductionconfig.ruresources:cpu:0.5memory_gb:1.3disk_size_gb:10当我转到我的项目目录并运行gcloudprevie
我有两个Rails模型,即Invoice和Invoice_details。一个Invoice_details属于Invoice,一个Invoice有多个Invoice_details。我无法使用accepts_nested_attributes_forinInvoice通过Invoice模型保存Invoice_details。我收到以下错误:(0.2ms)BEGIN(0.2ms)ROLLBACKCompleted422UnprocessableEntityin25ms(ActiveRecord:4.0ms)ActiveRecord::RecordInvalid(Validationfa
如何在ruby中调用C#dll? 最佳答案 我能想到几种可能性:为您的DLL编写(或找人编写)一个COM包装器,如果它还没有,则使用Ruby的WIN32OLE库来调用它;看看RubyCLR,其中一位作者是JohnLam,他继续在Microsoft从事IronRuby方面的工作。(估计不会再维护了,可能不支持.Net2.0以上的版本);正如其他地方已经提到的,看看使用IronRuby,如果这是您的技术选择。有一个主题是here.请注意,最后一篇文章实际上来自JohnLam(看起来像是2009年3月),他似乎很自在地断言RubyCL