2011-01-24 34 views
0


我试图将UIAlertView从屏幕中心的默认位置移动到顶部。我正在使用下面的代码,它适用于iOS 4,但它不会继续。3.
任何人有任何想法?CGAffineTransformTranslate无法在iOS 3.1.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]; 
+0

我不知道你期待发生什么,但'CGAffineTransformTranslate(someTransform,0,0)'只是要返回'someTransform'回您。 –

+0

,这就是为什么setTransform方法在下面一行使用。我认为语法是好的,因为它可以在iOS 4.0+上工作。 – Olsi

+0

即使我这样做:newSubscriptionAlertView.transform = CGAffineTransformTranslate(newSubscriptionAlertView.transform,0.0,0.0);我也有同样的问题。这意味着它在4上工作,但不在3上。:( – Olsi

回答

0

解决的办法是这样的:

 
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); 
    } 
相关问题