0
votes


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];
1
I don't know what you expect to happen, but CGAffineTransformTranslate(someTransform, 0, 0) is just going to return someTransform back to you. - Lily Ballard
and that's why the setTransform method is being used one row below. I think the syntax is ok, because it works on iOS 4.0+ - Olsi
Even if I do it this way: newSubscriptionAlertView.transform = CGAffineTransformTranslate(newSubscriptionAlertView.transform, 0.0, 0.0); I have the same problem. Meaning it works on 4 but not on 3. :( - Olsi

1 Answers

0
votes

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);
    }