如何保存图像的当前位置?

发布于 2025-01-05 00:08:35 字数 68 浏览 1 评论 0原文

我有一个应用程序,允许用户点击并在屏幕上移动 UITextField。有没有办法保存 UITextField 的当前位置?

I have a application that allows the user to tap and move a UITextField around the screen. Is there a way to save the current postion of the UITextField?

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

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

发布评论

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

评论(1

别在捏我脸啦 2025-01-12 00:08:35

在头文件中的某个位置,您想要创建一个 CGPoint 来存储当前位置。您还需要一个方法来保存 UITextField 的当前位置:

CGPoint currentLocation;
-(void) saveCurrentPosition;

当您想要保存当前位置时:

[self saveCurrentPosition];

saveCurrentPosition 应该如下所示:

- (void) saveCurrentPosition
{
    CGRect currentFrame = myTextField.frame;
    currentLocation = currentFrame.origin;
}

Somewhere in your header file, you want to make a CGPoint that stores the current location. You also want a method to save the current location of the UITextField:

CGPoint currentLocation;
-(void) saveCurrentPosition;

When you want to save the current position:

[self saveCurrentPosition];

saveCurrentPosition should look something like this:

- (void) saveCurrentPosition
{
    CGRect currentFrame = myTextField.frame;
    currentLocation = currentFrame.origin;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文