iphone - Display an App correctly on 3.5" and 4" screen -


i finished develop app. trying make nice in both iphone 4 , 5.

i trying height of scren following method doesn't work. idea?

cgrect screenbound = [[uiscreen mainscreen] bounds]; cgsize screensize = screenbound.size;  if (screensize.height == 1136) {     nslog(@"iphone 5"); }else if(screensize.height  == 960){     nslog(@"iphone 4 retina"); }else{     nslog(@"iphone 4 non retina"); } 

this complete viewwillappear method:

-(void)viewwillappear:(bool)animated { [[uidevice currentdevice] endgeneratingdeviceorientationnotifications];

cgrect screenbound = [[uiscreen mainscreen] bounds]; cgsize screensize = screenbound.size; nslog(@"%@",nsstringfromcgsize(screensize));  if (screensize.height == 568.0f) {     nslog(@"iphone 5"); }else if(screensize.height  == 480.0f){     nslog(@"iphone 4 retina"); }else{     nslog(@"iphone 4 non retina"); }   [firststepsbutton.titlelabel sethidden:yes]; [workingbutton.titlelabel sethidden:yes]; [accommodationbutton.titlelabel sethidden:yes]; [universitybutton.titlelabel sethidden:yes]; [meetmebutton.titlelabel sethidden:yes]; [improveyourselfbutton.titlelabel sethidden:yes];  self.navigationcontroller.navigationbarhidden = true; 

// self.view.backgroundcolor = [uicolor colorwithred:2/255.0f green:42/255.0f blue:97/255.0f alpha:1.0f];

[super viewwillappear:animated]; 

}

it wouldn't because screen's coordinate system in points, not pixels. try this:

cgrect screenbound = [[uiscreen mainscreen] bounds]; cgsize screensize = screenbound.size; nslog(@"%@",nsstringfromcgsize(screensize));  if (screensize.height == 568.0f) {     nslog(@"iphone 5"); }else if(screensize.height  == 480.0f){     nslog(@"iphone 4 retina"); }else{     nslog(@"iphone 4 non retina"); } 

you should consider using uidevice's userinterfaceidiom check whether device iphone/ipad, , uiscreen's scale determine whether device retina or not.


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -