News and Events Archives

Following is what px, in, mm, pt, dp, dip and sp stands for and what they means in Android.

px

Stands for : Pixels

It corresponds to actual pixels on the screen.

in
Stands for : Inches

It is based on the physical size of the screen.

mm
Stands for : Millimeters

It is based on the physical size of the screen.

pt
Stands for : Points

It represents1/72 of an inch based on the physical size of the screen.

dp or dip

Stands for : density independent pixel

The density-independent pixel is equivalent to one physical pixel on a 160 dpi (dots per inch) screen. At run time, the platform transparently handles any scaling of the dp units needed, based on the actual density of the screen in use. The conversion of dp units to screen pixels is simple: pixels = dps * (density / 160). Using dp units to define an application’s UI is highly recommended, as a way of ensuring proper display of UI on different screens. The compiler accepts both “dip” and “dp”, though “dp” is more consistent with “sp”.

sp
Stands for : Scale-independent Pixels

It is like the dp unit, but it is also scaled by the user’s font size preference. It is recommend to use this unit when specifying font sizes, so that it will be adjusted for both the screen density and user’s preference.

Incoming search terms:

  • android pt to sp conversion
  • convert pt to sp
  • difference between dip and px unit in windows
  • difference between pt and mm
  • difference pt mm
  • difference with mm and dip
  • what is differance between pt and mm

Jump to a Particular Line of Code in Xcode

In Xcode it is possible to jump to a particular line number of the opened file. The Jump in ‘openedfilename’… submenu under the Navigate menu of Xcode window will open the dialog box, where we can enter the line number to jump to and press enter to jump to that line of code.

 

We can also use the keyboard shortcut Command + L to open the dialog where the line number to jump to is to be entered,

It is possible to enable and disable the file path display using terminal. The method we are going to see here will display the file path in the title bar of the finder window.

For enabling path view, execute the following command in the terminal window of your mac.

Code:

Now restart the finder and you will be able to see the path of the file selected will be displayed on the title bar of the finder window.

For disabling path view in the title bar, execute the following command in the terminal window of your mac.

Code:

The simple way to enable the file path display in mac is using the view option of the finder. Go to the View menu of the finder. Then select the Show Path Bar submenu. Now of the path of the file selected will be shown at the bottom of the finder window. For disabling this, go to the View menu of finder. Now there we can see the Hide Path Bar submenu instead of the Show Path Bar. So select the Hide Path Bar submenu and it done. The path won’t displayed there at the bottom of the finder window.

Slowing down Animations in Xcode Simulator

It is possible to slow down animations in the Xcode simulator. This feature of Xcode simulator will allow you to better view animations over a longer period of time and also to spot inconsistencies and flaws in that.

To slow down animations, use the following steps :

1. Open the IOS Simulator app.

2. Go to the Hardware Menu.

3. Select the Toggle Slow Animations submenu.

This will slow down the animation that is currently running on the IOS simulator.

iPhone App Development Training in Singapore

Incoming search terms:

  • submenu animation ios

Simulating Memory Warning in Xcode Simulator

It is possible to simulate memory warning in the Xcode simulator. Memory warning in IOS is a condition of low available memory in the device. So this feature of Xcode simulator will help you to test how your application responds to such situations.

To simulate memory warning, use the following steps :

1. Open the IOS Simulator app.

2. Go to the Debug Menu.

3. Select the Simulate Memory Warning submenu.

This will simulate the memory warning situation of an IOS device in the simulator.

iPhone App Development Training in Singapore

Incoming search terms:

  • xcode low memory

The following lines of code can be used for changing the keyboard language programmatically in Xcode.

Incoming search terms:

  • xcode change keyboard language
  • using nsuserdefaults to change language xcode
  • air keyboard xcode code
  • xcode set locale programmatically
  • xcode set keyboard language
  • xcode iphone keyboard language
  • xcode change keybaord language
  • xcode add new keyboard language to iphone
  • nsuserdefaults key to force keyboard language
  • how to change iphone keyboard language setting programmatically

We can escape the percentage symbol inside string in objective C using the percent symbol itself.

So if you want to add a % to a string, you have to add as follows :

If the value of myMarkPercentage variable is 80, then if we display the above string in the console, we will get the text as :

 

Output:

I got 80% marks in exam.

Using Multi-input Methods in Objective C

In Objective-C, a method name can be split into several segments. In the declaration part, a multi-input method looks like the following:

-(BOOL)writeToFile:(NSString *)path atomically:(BOOL)useAuxiliaryFileornot; // Here, this method has two parameters – first parameter is the path, which is a NSString object and second one is useAuxiliaryFileornot, which is a boolean object. This method returns a boolean value.

We can call this method as follows:

BOOL result = [myDataToWrite writeToFile:@"/myfolder/log.txt" atomically:NO]; // In this section, we are calling the multi-input method and the boolean value that it returns is assigned to the object result.

Calling Methods in Objective C

The basic syntax for calling a method using an object in xcode is as follows:

Let’s consider an object named myObject. We can call methods using the object as follows:

[myObject myMethod]; // Here we are calling the method named myMethod using the object myObject.

[myObject myMethodWithInput:input]; // Here we are calling the method named myMethodWithInput using the object myObject. This method has a parameter and hence we are passing that as the argument. In this line,’input’ is the argument that we are passing.

Methods can also return a value:

myOutput = [myObject myMethodWithOutput]; // Here we are calling the method named myMethod using the object myObject, which returns a value. Here myOutput will contain the return value of the method.

myOutput = [myObject myMethodWithInputAndOutput:input]; // Here we are calling the method named myMethodWithInput using the object myObject and parameter as input. Here myOutput will contain the return value of the method.

 

 

Page 1 of 1912345...10...Last »