Skip to content

CrossApp Adaptation Solution

9miao edited this page Sep 9, 2014 · 1 revision

CrossApp Adaptation Solution

A perfect screen adaptation solution is hardly to be created, since a solution is impossible to apply to all devices. When an App is running on different devices, some UI elements of an interface might change on account of devices’ physical size and resolutions are not exactly the same, here these matters need to be controlled by developer their own in most conditions, and we suggest you to use relative coordinates as much as possible in programs.

When our App is running on a lower PPI device, its interface might be zoomed in, whereas might be zoomed out on a higher PPI device, However, actually sometime our hope is that UI elements stay the same. so for some UI elements that have fixed size, we need to unify and fix its displayed size on different devices, such as the text font size of 9miao Reader, and make the larger screen device display more contents, for this matter, we can fix each cell size of tableView so as to make much more cells are displayed on larger screen. CrossApp provides a kind of assistant adaptation solution.

Taking iPhone 4 and iPhone 5 as standard to adapt and the relative parameters are shown below:

device

screen size

resolution

PPI

iPhone 4

3. 4 inch

960*640

326

iPhone 5

4. 0 inch

1136*640

326

CrossApp assistant adaptation solution’s principle is to stay UI physical size the same as close as possible, but there will be still a chance that minor changes appear and the specific change value is determined by system. In a fixed UI physical size condition, PPI and its display effect varies from different devices, the one who owns larger size screen display more content, and its PPI value number decides the resolution degree.

Here we introduce a correction factor concept, iPhone 4 and iPhone 5’s correction factor is 1 because of these two device are our standard, but for other device this factor is an approximate value. When we set UI size, if we are required to display it in a same size on different devices, generally we need to multiply this correction factor, and CrossApp will auto calculate its value according to different device’s specification, then we can obtain this new factor via a macro.

1

#define CROSSAPP_ADPTATION_RATIO CAApplication: : getApplication()->getAdaptationRatio()

PPI: pixel per inch, PPI is generally used to show device screen’s resolution on iOS device.

DPI: dot per inch, DPI generally is used to show device screen’s resolution on Android device. In normal conditions, PPI and DPI can express same concept, and the former one is mainly specific to display device, and the latter one is more applied to print and output device, but these two all mean the pixel that per inch contains.

Clone this wiki locally