iphone:在哪里编写此代码?

发布于 2024-12-09 16:03:31 字数 898 浏览 4 评论 0原文

实际上我是 iphone 开发的新手,想为此实现 Toast 我找到了一个 stackoverflow 帖子 iPhone 中的 Android Toast?

现在的问题是,这里在一篇文章中给出了 Toast 的代码但我不知道我需要在哪种类型的文件中编写此代码才能工作......

using System;
using System.Drawing;
using MonoTouch.UIKit;
namespace General
{

    public class ToastSettings
    {
        public ToastSettings ()
        {
            this.Duration = 500;
            this.Gravity = ToastGravity.Center;
        }

        public int Duration
        {
            get;
            set;
        }

        public double DurationSeconds
        {
            get { return (double) Duration/1000 ;}

        }

        public ToastGravity Gravity
        {
            get;
            set;
        }

        public PointF Position
        {
            get;
            set;
        }    

    }
}

Actually I am new to iphone development and want to implement Toast for this I find a stackoverflow post
Android Toast in iPhone?

Now the problem is, here a code is given in one post for Toast but I donot know that in which type of file i need to write this code to work...

using System;
using System.Drawing;
using MonoTouch.UIKit;
namespace General
{

    public class ToastSettings
    {
        public ToastSettings ()
        {
            this.Duration = 500;
            this.Gravity = ToastGravity.Center;
        }

        public int Duration
        {
            get;
            set;
        }

        public double DurationSeconds
        {
            get { return (double) Duration/1000 ;}

        }

        public ToastGravity Gravity
        {
            get;
            set;
        }

        public PointF Position
        {
            get;
            set;
        }    

    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

挽梦忆笙歌 2024-12-16 16:03:32

您的代码是用 Java 编写的,在 iPhone 开发中您不能简单地添加该代码。您需要将其转换为 Objective C 并然后使用它。至于此代码的放置位置,您可以为其创建一个单独的文件并在您的委托中引用它,或者您可以简单地将其放置在您的委托本身中(不推荐)。

但是,查看您链接的帖子,您应该简单地使用以下内容:http ://code.google.com/p/toast-notifications-ios/wiki/HowToUse

它有关于如何在 iPhone 开发中使用 Toast 的详细信息和代码,甚至还用 Objective C 完成了代码

。你是 iPhone 开发新手建议您阅读以下教程:
https://stackoverflow.com/questions/1939/how- 首先阅读-articles-for-iphone-development-and-objective-c

学习如何正确使用 xcode 和 Objective C。一旦您熟悉了 IDE,我相信您就可以轻松编码和创建项目。

You code is in Java, and in iPhone development you cant simply add that code in. You will need to convert it into Objective C and use it then. As to where this code will be placed, you can either create a separate file for it and reference it in your delegate or you can simply place this in your delegate itself(not recommended).

However, looking at the post you linked, you should simply use this: http://code.google.com/p/toast-notifications-ios/wiki/HowToUse

It has the details and code on how to use Toast in iPhone development and even has the code done up in objective C.

If you are new to iPhone development I suggest you go through the tutorials:
https://stackoverflow.com/questions/1939/how-to-articles-for-iphone-development-and-objective-c

first and learn how to use xcode and Objective C properly. Once you are comfortable with the IDE, I am sure you can code and create your project easily.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文