Thursday, 25 July 2013

Fix Linker command fail error when archiving for Xcode 4.6 with phonegap v2.9


  1. In your Target's Build Settings, find Other Linker Flags
  2. Change $(TARGET_BUILD_DIR)/libCordova.a
  3. To $(BUILT_PRODUCTS_DIR)/libCordova.a
from:Building an archive for XCode 4.6 release with phonegap v 2.9 fails

Thursday, 9 May 2013

iOS Devices Dimensions

Description iPhone  iPhone RetinaiPadiPad Retina         
     Dimensions     320 x 480       640 x 960 1024 x 768  2048 x 1532
     Status bar           20             20         20           20
     App icon       57 x 57       114 x 114     72 x 72     144 x 144




Friday, 3 May 2013

Handling img click event on mobile devices

The following is the snippet for handling click event on mobile devices:

<script>
    var touchflag = false;
          $("img").bind("touchstart", function(event)
              {
                 touchflag = false;
              }); 

          $("img").bind("touchmove", function(event)
             {
                touchflag = true;
             }); 

          $("img").bind("touchend", function(event)
            {
            if(touchflag) return;
           
            name = $(this).parent().attr("id");
            window.open("pageToOpen.html?q="+name,"_self");
          }); 

</script>

Tuesday, 20 November 2012

Show/Hide invisible files in Mac OS

In terminal, type the following:

defaults write com.apple.Finder AppleShowAllFiles YES/NO 
And to unhide Files/Folders:

  sudo chflags nohidden ~/Folder

unhide all subFolder and files:

  sudo chflags -R nohidden ~/Folder

Monday, 12 November 2012

PHP set(display) local time and locale

<?php
//set timezone
$timezone_offset = +8;
$current_time = gmdate('H:i:s', time()+$timezone_offset*60*60);

echo "Current time is $current_time. "

$loc_uk = setlocale(LC_ALL, 'eng');
echo "Preferred locale on this system is $loc_uk";

?>

For supported locale for windows, see here.

Friday, 26 October 2012

Hide keyboard programmatically in iOS

1. Add the following code to the implementation file (.m)

-(void) textFieldShouldReturn:(UITextField *)textField
{
    [textField resignFirstResponder];
}

And in the header file (.h)
-(void)textFieldShouldReturn:(UITextField *)textField

2. Add target to the textField:
txtField.delegate = self;
[txtField addTarget:self action:@selector(textFieldShouldReturn:)
          forControlEvents:UIControlEventTouchCancel];

That's it! Test it out. Hope you find this useful. 



Adding Customized Font in iOS Project

1. Download your custom font file, and add it to the Xcode project.

2. In the project.plist file, add a row, type in "Fonts provided by application ", and int the item row,
write your desired name.










3. And don't forget to check the target membership. 

Then you can use it whenever you want by:

textField.font =[UIFont fontWithName:@"HelveticaRoundedLTStd-Bd" size:12];

If you are not sure about the font name, you can open the font file in FontForge and check.

But be warned if you added more than 2 custom fonts from the same family, because iOS does not allow to do that. In that case, you can find a solution here.