0
votes

I would like to get the current dimension of the screen. i used self.view.frame.size.width

NSLog(@"%f",self.view.frame.size.width)

so when I run in the iphone simulator , it will return 320 however, when i run in the ipad simulator, it will still return me 320

I have different nib files for iphone and ipad and they're getting the proper nib files and the target family is ipad/iphone it should return 768 and so i can resize the images according to that.

any ideas?

5
To get screen dimension you can use this: [[UIScreen mainScreen] bounds].size.height/width. I don't post it as an answer since I don't answer your question about the same value on iPhone and iPad. Still, I hope it will help :)FreeNickname
In which method did you place the NSLog?Levi
Your title is a bit misleading. Gives the impression that they are returning different values which would make sense. Can you please change your title to be more accurate.Popeye
Do you use ~ipad postfix of the NIB filename for iPad?art-divin
just to clarify, have you changed the Devices to Universal in Targets->Summary page in Xcode?Ushan87

5 Answers

2
votes

try and use these

CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width;
CGFloat screenheight = [UIScreen mainScreen].bounds.size.height;

but UIScreen doesn't take into account the current interface orientation. you will have to check for that also

or directly check for the device type

if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)

and

if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
1
votes

Change your targeted devices to Universal as in this picture

enter image description here

0
votes

Is your iPad Nib file being used when running in a iPad Simulator? Maybe you want to check by changing something (maybe, change the location of,say, a button) in the iPad's NIB. This way, when the App runs, you can check if it's the iPhone's NIB or iPad's Nib.

0
votes

First you check this:-

if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) and

if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)

And also while allocating file:-

For iPhone:- ABController *controller = [[ABController alloc] initWithNibName:@"ABController~iPhone" bundle:nil];

For iPad:- ABController *controller = [[ABController alloc] initWithNibName:@"ABController~iPad" bundle:nil];

0
votes

Make sure that

 self.view.autoresizesSubviews=NO;
 Imageview.autoresizingMask=NO;

is set to NO.

That will do your work