views:

43

answers:

1

I had a UIAlertView window which worked fine in iPhone OS 3.2.3, with SDK 3.1.3 and XCode 3.2.1.

But after I updated the iPhone to OS 4.0 by iTunes, consequently had to upgrade the SDK to 4.0 (with XCode 3.2.3), the UIAlertView window turns out too high when popping up, and only drops down to the correct position after the textField is tapped with the keyboard pops out.

Please see the screenshots below:

As I do not have 10 reputations to post images here, please refer to http://www.iphonedevsdk.com/forum/iphone-sdk-development/51160-alertview-too-high-os4.html#post214228 for the screenshots. Sorry for this.

The relevant code is below:

wpName = [[UITextField alloc] initWithFrame:CGRectMake(12, 45, 260, 25)];
[wpName setBackgroundColor:[UIColor whiteColor]];
[wpName setPlaceholder:@"Your Name"];
[describeWP addSubview:wpName]; 

wpDescrip = [[UITextField alloc] initWithFrame:CGRectMake(12, 80, 260, 25)];
[wpDescrip setBackgroundColor:[UIColor whiteColor]];
[wpDescrip setContentVerticalAlignment:UIControlContentVerticalAlignmentCenter]; 
[wpDescrip setPlaceholder:@"Phone number, Company"];
[describeWP addSubview:wpDescrip];

CGAffineTransform moveUp = CGAffineTransformMakeTranslation(0, 90);
[describeWP setTransform:moveUp];

Could you guys shed some lights please? Thanks a lot!

A: 

Assuming that describeWP is your UIAlertView, the problem is that you are moving the view up in your code. Try removing the following lines:

CGAffineTransform moveUp = CGAffineTransformMakeTranslation(0, 90);
[describeWP setTransform:moveUp];
Will Harris
Thanks Will, I finally found that it is the problem of the Simulator in the XCode 3.2.3 for SDK 4. I found out the problem and solution: the AlertView window only comes out too high when the "Base SDK" is set to "Simulator/Device 4.0", no matter what you set in "iPhone OS Deployment Target". After I use "Simulator/Device 3.2" for "Base SDK", the AlertView window works fine. Check http://www.iphonedevsdk.com/forum/iphone-sdk-development/51160-alertview-too-high-os4.html for some relevant info.
lionfly
Yes in iOS4, the above 2 lines should be removed. Only in previous iOS the above 2 lines are necessary not to let the keyboard cover a bit of the alertview. Thanks.
lionfly