dimanche 28 décembre 2014

UItableviewcell wonky display, they just can't get the screen width correctly with iphone6+. (objc)

I just made a login screen using uitableviewcell instead of uiscrollview for simplicity, but it turned out to be a disaster.


I color the cell green so you can see it clearly. Here's how it looks in iPhone6+: enter image description here


And here's how it looked in iPhone 5: enter image description here


So the problems here are the UILabel and UITextField doesn't get the ip6+ screensize. I use this code to set them up which should be getting the correct screen size



screenWidth = [[UIScreen mainScreen] bounds].size.width;
UITableViewCell *cell = [[UITableViewCell alloc] initWithFrame:CGRectMake(0, 0, screenWidth, 44)];
UITextField *field = [[UITextField alloc] initWithFrame:cell.contentView.layer.bounds];
OR
UILabel *uiLabel = [[UILabel alloc] initWithFrame:cell.contentView.frame];


My main question would be, if UIScreen doesn't work, how do we get proper width for iphone 6+ ??




Aucun commentaire:

Enregistrer un commentaire