Sep 19, 2013

The scale and width for mobile device

To maintain the consistent layout and make and make the view unable to be scaled.
Enter the following meta segment into html header section.



Hmm...., that's all!
If you wish to know more, refer to http://dev.w3.org/csswg/css-device-adapt/

Jan 29, 2013

PHP: Weird scope of variables

First of all, this post is simply a note that reminds me of something basic but important in PHP programming....


In PHP, except member variables of a class, all the PHP variables are available once it is assigned with some values even if it's surrounded by a set of brackets.

Generally, brackets in C/C++ has the effect of limiting the affective scope of a variable.
Considering the following two code segments of func1 and func2.

//test1.cpp
void func1()
{
    int a = 5;
    a++;
}

//test2.cpp
void func1()
{
    if(true)
    {
        int a = 5;
    }
    a++;
}

If you try to compile these segments, the compiler will throw the following error message:
    test.cpp: In function ‘void func()’:
    test.cpp:7: error: ‘a’ was not declared in this scope

As you can see, the declarations surrounded by a set of brackets will be treated as a local variable that lives and existed in the bracket.

But in PHP, the following code segments of func3 and func4 will execute without errors and and return the same value of 6.


function func3()
{
    $a = 5;
    $a++;

    return $a;
}
function func4()
{
    if(true)
    {
        $a = 5;
    }
    $a++;

    return $a;
}

 Base on theses examples, I have to be careful in writing PHP code and try to avoid mistakened variable rewriting......

Jan 4, 2013

The 'static' Keyword in C/C++

Recently I discovered that there're still a number of people doesn't know what does the keyword 'static' do exactly!!! Well then, here comes my tutorial of 'static'.

In brief, the static keyword does only one thing, it tells the program to allocate and maintain a number of fixed memory space to store the variable before the program start to execute, and treat the scope of static variables as the ordinary ones.

Jan 2, 2013

Objective-C Cookbook - 01 - Preparations

Here in this series of objective-c cookbook series, I am gonna arrange all my experiences in learning objective-c and present them in a more readable structure. I hope this will lower down the barrier of learning such an appealing language.

This cookbook is for ones who have programming experiences and already know the basics of programming languages, which means, some basic concepts like variable, basic types and operators will not be mentioned in this cookbook.

Jul 2, 2012

iOS Basic Sizes

Window 320 x 480 points
Status Bar height 20 points

Navigation Bar height 44 points
Navigation Bar Image 20 x 20 points

Tab Bar height 49 points
Tab Bar Icon 30 x 30 points

Portrait Keyboard height 216 points
Landscape Keyboard height 162 points

*points in iPhone4 = 2 pixels (retina display)