Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 06-24-2010, 08:31 AM   #1 (permalink)
Registered Member
 
Join Date: Mar 2010
Posts: 20
lionfly is on a distinguished road
Default AlertView too high with OS4

I had a UIAlertView window which worked fine in iPhone OS 3.1.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:




The relevant code is below:
Code:
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!

Last edited by lionfly; 06-25-2010 at 09:03 AM. Reason: correct an error: iPhone OS 3.2.3 -> iPhone OS 3.1.3
lionfly is offline   Reply With Quote
Old 06-24-2010, 11:07 AM   #2 (permalink)
Registered Member
 
Join Date: Jan 2009
Location: Long Beach, CA
Posts: 612
bytor99999 is on a distinguished road
Send a message via AIM to bytor99999 Send a message via Yahoo to bytor99999
Default

Well basically, you did it to yourself.

I do the same thing, so I am just joking there.

But you are using the UIAlertView differently than Apple "recommends".

You added UITextFields, and therefore had to move the alert view yourself with the transform. I do this in my app.

Well, the reason why apple says, use the public apis, and as we recommend you using them, is because they give no guarantee that what you wrote will work in newer versions. And here is an example of such a case.

I recommend the transform code be put into an if statement, where you check what version the OS is, if it is below 4.0 do the transform. If it isn't then don't.

And let us know if that works.

Thanks

Mark
__________________
Perfect World Programming LLC
http://www.perfectworldprogramming.com

Please check out my apps.

TubeOrganizer
http://www.spritzlerapps.com/tube-organizer.html

Paper Clips
http://spritzlerapps.weebly.com/paper-clips.html
bytor99999 is offline   Reply With Quote
Old 06-24-2010, 09:48 PM   #3 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 107
JDave is on a distinguished road
Default

Your code:

Code:
wpName = [[UITextField alloc] initWithFrame:CGRectMake(12, 45, 260, 25)];
is the problem... maybe working with ratios is what you need... ratios of 320 x 480 if you catch my drift.

try something like:

Code:
CGRectMake(12/320*[[UIScreen mainScreen] bounds].size.width, 45/480*[[UIScreen mainScreen] bounds].size.height, blah blah........
I am not sure, but the Alert's 'jump' is likely related to the OS overridding your overrided UIAlertView's location on the screen... but it may be related to your transform.

Last edited by JDave; 06-24-2010 at 09:53 PM.
JDave is offline   Reply With Quote
Old 06-25-2010, 10:54 AM   #4 (permalink)
Registered Member
 
Join Date: Mar 2010
Posts: 20
lionfly is on a distinguished road
Default

Thanks guys for the suggestions.

Using the AlertView this way will not be refused by Apple, I believe, though maybe not "recommended". But anybody has a better way of getting a popped window out to pick some text inputted by user? Please provide suggestions.

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.

However, this is a BIG however, the XCode 3.2.3 comes with SDK 4.0, which is the only choice for building for iPhone OS4, does not provide the right iPhone Simulator! If you pick "Simulator 3.2", it always comes out the iPad Simulator, and your iPhone app does not simulate there properly. If you pick "Simulator 4.0", though the UI looks like a iPhone, but functions are still not responding, e.g. tables cannot roll, maps cannot move, etc.

No other SDK options in XCode 3.2.3.

In the end, I installed the previous XCode 3.2.1 with SDK 3.1.3 into another directory, to Simulate with SDK 3.1.3, and build into the iPhone OS4 with the XCode 3.2.3 from SDK 4.
lionfly is offline   Reply With Quote
Old 06-29-2010, 01:22 AM   #5 (permalink)
Registered Member
 
Join Date: Sep 2009
Posts: 14
learnSomething is on a distinguished road
Default

your issue is because of

CGAffineTransform moveUp = CGAffineTransformMakeTranslation(0, 90);


do something like:
Code:
if ([[[UIDevice currentDevice] systemVersion] floatValue] < 4.0) {
	CGAffineTransform moveUp = CGAffineTransformMakeTranslation(0, 90);
}
oh, and of course you have to adjust the x,y values of your UITextField for iOS 4. (do if(blabla))
learnSomething is offline   Reply With Quote
Old 07-06-2010, 09:23 AM   #6 (permalink)
Registered Member
 
Join Date: Mar 2010
Posts: 20
lionfly is on a distinguished road
Default

Thanks LearnSomething, it is not because of
Code:
CGAffineTransform moveUp = CGAffineTransformMakeTranslation(0, 90);
which is to move it up a bit to avoid the keyboard covering the alertView box. You see the correct screenshot when the keyboard pops up.
lionfly is offline   Reply With Quote
Old 08-05-2010, 05:33 AM   #7 (permalink)
Registered Member
 
Join Date: Mar 2010
Posts: 20
lionfly is on a distinguished road
Default

I have found the same error for the alertView of the "Orange Weds" 241 film tickets App, which is too high in the iPhone 4. See the screenshot:



So different code should be used for OS 4, just as "learnSomething" said.
lionfly is offline   Reply With Quote
Old 08-05-2010, 07:41 AM   #8 (permalink)
Registered Member
 
Join Date: Nov 2008
Posts: 864
nobre84 is on a distinguished road
Default

It is the affine transform indeed, just remove it or adjust the correct value to shift up conditionally when device uses OS4. And you cannot avoid using Base SDK 4.0 , it is the only proper way to support fast app switching, and I believe Apple will not allow anything built below it.
nobre84 is offline   Reply With Quote
Reply

Bookmarks

Tags
iphone, os 4.0, uialertview

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 323
7 members and 316 guests
anothermine, Chickenrig, Domele, givensur, michaelhansen, PixelInteractive, Sloshmonster
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,657
Threads: 94,118
Posts: 402,892
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jenniead38
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 12:21 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0