我有两个函数调用 setInterval 但我需要它们是同步的。这是我的代码(是的,它们非常简单)。
var number1 = 0;
function caller(){
go();
come();
}
function go() {
anim1 = setInterval("doActionGo()", 20);
}
function come() {
anim2 = setInterval("doActionCome()", 20);
}
function doActionGo(){
if(number1 < 1023) {
number1++;
} else {
clearInterval(anim1);
}
}
function doActionCome() {
if (number1 > 0) {
number1 = number1 - 1
} else {
clearInterval(anim2);
}
Run Code Online (Sandbox Code Playgroud)
函数 doActionGo() 和 doActionCome() 可以是任何代码。有人知道如何解决吗?
问候!
我正在尝试使用Google API在我的应用程序中放置一些图形,但它不适用.我在互联网上测试了其他图像的代码并且有效.
码:
- (void)viewDidLoad {
[super viewDidLoad];
UIImage *myimage = [UIImage imageWithData: [NSData dataWithContentsOfURL: [NSURL URLWithString: @"http://chart.apis.google.com/chart?cht=bvo&chd=t:10,50,60,80,40&chl=Hello|World|hi&chs=250x100"]]];
UIImageView *test = [[UIImageView alloc] initWithImage:myimage];
UIView *myView = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, 100.0, 100.0)];
[myView addSubview:test];
[self.view addSubview:myView];
}
Run Code Online (Sandbox Code Playgroud)
谢谢,克劳迪奥
我正在尝试使用Monotouch在.Net中为iPhone创建一个项目.我的问题是:
我有一个由Visual Studio 2010生成的DLL.这个DLL只有一个接口和另外两个类.我可以在Visual Studio中的项目中使用没有问题,但是当我尝试在Monotouch中使用相同的那个时,我遇到了这个错误:
构建:HelloWorld(Debug | iPhoneSimulator)
构建解决方案HelloWorld
构建:HelloWorld(Debug | iPhoneSimulator)
执行主编译...
更新CodeBehind文件
更新了MainWindow.xib.designer.cs
/ Developer/MonoTouch/usr/bin/smcs/noconfig"/out:/Users/claudio/Documents/Development/DotNet/HelloWorld/HelloWorld/bin/iPhoneSimulator/Debug/HelloWorld.exe""/ r:/ Developer/MonoTouch/usr/lib/mono/2.1/System.dll""/ r:/Developer/MonoTouch/usr/lib/mono/2.1/System.Xml.dll""/ r:/ Developer/MonoTouch/usr/lib/mono/2.1/System.Core.dll""/ r:/Developer/MonoTouch/usr/lib/mono/2.1/monotouch.dll""/ r:/Developer/MonoTouch/usr/lib/mono/2.1/System.Runtime. Serialization.dll""/ r:/Developer/MonoTouch/usr/lib/mono/2.1/System.ServiceModel.dll""/ r:/Developer/MonoTouch/usr/lib/mono/2.1/System.ServiceModel.Web. dll""/ r:/Users/cassette/Files/Development/DotNet/Hello World/HelloWorldfull/optimize-/codepage:utf8"/ define:DEBUG"/ t:exe"/Users/claudio/Documents/Development/DotNet/HelloWorld/HelloWorld/MainWindow.xib.designer.cs"
"/Users/claudio/Documents/Development/DotNet/HelloWorld/HelloWorld/Main.cs""/Users/claudio/Documents/Development/DotNet/HelloWorld/HelloWorld/Class1.cs"
程序集中缺少方法.ctor /Users/claudio/Documents/Development/DotNet/HelloWorld/HelloWorld/bin/Abcom.EmailService.ContractsCS.dll,类型System.Runtime.Versioning.TargetFrameworkAttribute类System.Runtime.Versioning.TargetFrameworkAttribute不能在Abcom.EmailService.ContractsCS中使用加载,无法找到自定义attr构造函数图像:/Users/claudio/Documents/Development/DotNet/HelloWorld/HelloWorld/bin/Abcom.EmailService.ContractsCS.dll mtoken:0x0a000001未处理的异常:System.TypeLoadException :无法从程序集"Abcom.EmailService.ContractsCS"加载类型"System.Runtime.Versioning.TargetFrameworkAttribute".at(包装器托管到本机)System.Reflection.Assembly:System.Reflection.Assembly.GetType(System.String name,Internal.SetType(System.Reflection.Module,string,bool,bool)
有人知道这里发生了什么吗?
此致,克劳迪奥
我正在尝试创建自己的BackBarButtonItem,但我遇到了一些问题.
我的声明:
var backButon = new UIBarButtonItem("Back",UIBarButtonItemStyle.Plain, null, null);
Run Code Online (Sandbox Code Playgroud)
例外:
Unhandled Exception: System.ArgumentNullException: Argument cannot be null.
Parameter name: target
Run Code Online (Sandbox Code Playgroud)
我应该在"目标"和"行动"参数中加入什么?
我正在使用SQLite.cs包装器帮助我使用数据库,我有这种方法用于从表创建XML,这很好.
public void GenerateInvoiceXML(string filePath) {
var invoices = app.db.Table<Invoice>().ToList();
XmlSerializer serializer = new XmlSerializer( typeof(List<Invoice>) );
TextWriter writer = new StreamWriter(filePath);
serializer.Serialize(writer,invoices);
writer.Close();
}
Run Code Online (Sandbox Code Playgroud)
我拥有的所有表都是这样定义的:
[Serializable]
public class Invoice
{
[PrimaryKey, AutoIncrement]
public int Id { get; set; }
public string Supplier {get; set;}
public string Date {get; set;}
public string PaymentMethod {get; set;}
public string Notes {get; set;}
public Invoice(int newID)
{
Id = newID;
}
public Invoice()
{
}
}
Run Code Online (Sandbox Code Playgroud)
但我想改变这种方法,如下所示:
public void GenerateInvoiceXML(string filePath, Type table) …Run Code Online (Sandbox Code Playgroud)