CGAffineTransformTranslate 在 iOS 3.1.3 中不起作用

发布于 2024-10-14 16:20:08 字数 1091 浏览 2 评论 0原文


我正在尝试将 UIAlertView 从屏幕中心的默认位置移动到顶部。我使用下面的代码,它可以在 iOS 4 上运行,但不能在 3 上运行。
有人有什么想法吗?

UIAlertView *newSubscriptionAlertView = [[UIAlertView alloc] initWithTitle:@"Ndrysho abonimin" message:@" " delegate:self cancelButtonTitle:@"Anullo" otherButtonTitles:@"Ruaj", nil];
    subscriptionNameField = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 45.0, 260.0, 22.0)];
    subscriptionNameField.text = [[subscriptions objectAtIndex:changeCode] title];
    subscriptionNameField.autocorrectionType = UITextAutocorrectionTypeNo;
    subscriptionNameField.autocapitalizationType = UITextAutocapitalizationTypeNone;
    [subscriptionNameField setBackgroundColor:[UIColor whiteColor]];
    [newSubscriptionAlertView addSubview:subscriptionNameField];
    [subscriptionNameField becomeFirstResponder];
    [subscriptionNameField release];
    CGAffineTransform moveUp = CGAffineTransformTranslate(newSubscriptionAlertView.transform, 0.0, 0.0);
    [newSubscriptionAlertView setTransform:moveUp];
    [newSubscriptionAlertView show];
    [newSubscriptionAlertView release];

I'm trying to move a UIAlertView from it's default position in the center of the screen, up to the top. I'm using the code below and it works on iOS 4, but it doesnt move on 3.
Anyone has any idea?

UIAlertView *newSubscriptionAlertView = [[UIAlertView alloc] initWithTitle:@"Ndrysho abonimin" message:@" " delegate:self cancelButtonTitle:@"Anullo" otherButtonTitles:@"Ruaj", nil];
    subscriptionNameField = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 45.0, 260.0, 22.0)];
    subscriptionNameField.text = [[subscriptions objectAtIndex:changeCode] title];
    subscriptionNameField.autocorrectionType = UITextAutocorrectionTypeNo;
    subscriptionNameField.autocapitalizationType = UITextAutocapitalizationTypeNone;
    [subscriptionNameField setBackgroundColor:[UIColor whiteColor]];
    [newSubscriptionAlertView addSubview:subscriptionNameField];
    [subscriptionNameField becomeFirstResponder];
    [subscriptionNameField release];
    CGAffineTransform moveUp = CGAffineTransformTranslate(newSubscriptionAlertView.transform, 0.0, 0.0);
    [newSubscriptionAlertView setTransform:moveUp];
    [newSubscriptionAlertView show];
    [newSubscriptionAlertView release];

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

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

发布评论

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

评论(1

梦归所梦 2024-10-21 16:20:08

解决方案是这样的:

if (!([[[UIDevice currentDevice] systemVersion] floatValue] > 4.0)) {
//This is for iOS versions below 4.0
        changeFolderAlertView.transform = CGAffineTransformMakeTranslation(0.0f, 70.0f);
    } else {
//This is for iOS4.0+
        changeFolderAlertView.transform = CGAffineTransformMakeTranslation(0.0f, 0.0f);
    }

The solution is this:

if (!([[[UIDevice currentDevice] systemVersion] floatValue] > 4.0)) {
//This is for iOS versions below 4.0
        changeFolderAlertView.transform = CGAffineTransformMakeTranslation(0.0f, 70.0f);
    } else {
//This is for iOS4.0+
        changeFolderAlertView.transform = CGAffineTransformMakeTranslation(0.0f, 0.0f);
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文