我试图将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];
答案 0 :(得分: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); }