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 = [[订阅 objectAtIndex:changeCode] title];
    subscriptionNameField.autocorrectionType = UITextAutocorrectionTypeNo;
    subscriptionNameField.autocapitalizationType = UITextAutocapitalizationTypeNone;
    [subscriptionNameField setBackgroundColor:[UIColor whiteColor]];
    [newSubscriptionAlertView addSubview:subscriptionNameField];
    [订阅名称字段成为FirstResponder];
    [订阅名称字段发布];
    CGAffineTransform moveUp = CGAffineTransformTranslate(newSubscriptionAlertView.transform, 0.0, 0.0);
    [newSubscriptionAlertView setTransform:moveUp];
    [newSubscriptionAlertView 显示];
    [newSubscriptionAlertView 发布];
4

1 回答 1

0

解决方案是这样的:

if (!([[[UIDevice currentDevice] systemVersion] floatValue] > 4.0)) {
//这是针对4.0以下的iOS版本
        changeFolderAlertView.transform = CGAffineTransformMakeTranslation(0.0f, 70.0f);
    } 别的 {
//这是iOS4.0+
        changeFolderAlertView.transform = CGAffineTransformMakeTranslation(0.0f, 0.0f);
    }
于 2011-01-25T14:09:15.807 回答