Friday, June 15, 2012

iOS -- number convert to english number

This is a app is to convert number to string, so far is up to billion. For example, 101 change to one hundred one, 11 change to eleven.

Here is the view:







Here is some explanation:

1.  Define the data

2.  Here is the recursion

     NSString *prefix = [self english_num:write];

     
 To download the code from Github, here is link:

  https://github.com/MatthewLu/numberConvert

Thursday, June 14, 2012

Javascript-- Style set Attribute not working in IE7

In some case, we want to add a style to DOM element , normally  you will do like this,




this will work in most cases, but some time when you are working for IE7 or IE6, this will not work,

so the solution as below:



Now you can add css style to Dom element in IE7 or IE6

Javascript-- Ajax cross domain for Jquery

Sometime we want to trigger a Ajax call cross other web domain,

For example, we are in www.abc.com , and you want to call a Ajax to www.123.com, you will



It will work in Firefox and Chrome, but sometimes in IE, especially for IE7 and IE6, it will not trigger this Ajax call because your call is from abc.com to 123.com.


So the solutions as fellow:





Now you can access 123.com method from abc.com.



Tuesday, June 5, 2012

Monday, June 4, 2012

iOS -- Working with Images

Reading Image Data

 1. UIImage Convenience Methods
     myImage = [UIImage imageNamed:@"icon.png"];

 2. Finding Images in the Sandbox
     NSArray *paths = [NSSearchPathForDirectoriesInDomains(
     NSDocumentDirectory, NSUserDomainMask, YES);
     return [paths lastObject];

     NSString *documentsFolder()
    {
      return [NSHomeDirectory()
      stringByAppendingPathComponent:@"Documents"];
     }

    path = [documentsFolder() stringByAppendingPathComponent:@"image.png"];
    return [UIImage imageWithContentsOfFile:path];


 3.Loading Images from URLs
    NSURL *url = [NSURL URLWithString:
    @"http://image.weather.com/images/maps/current/curwx_600x405.jpg"];

    UIImage *img = [UIImage imageWithData:
    [NSData dataWithContentsOfURL:url]];


    load itself asynchronously without blocking the main thread


   // Create an asynchronous background queue

    NSOperationQueue *queue = [[NSOperationQueue alloc] init];
    [queue addOperationWithBlock:
    ^{
      // Load the weather data

      NSURL *weatherURL = [NSURL URLWithString:@"http://image.weather.com/images\
      /maps/current/curwx_600x405.jpg"];

      NSData *imageData = [NSData dataWithContentsOfURL:weatherURL];

     // Update the image on the main thread using the main queue

    [[NSOperationQueue mainQueue] addOperationWithBlock:^{

    UIImage *weatherImage = [UIImage imageWithData:imageData];

    imageView.image = weatherImage;}];