Customize the background of Tab Bar in iPhone SDK

Customize the background of Tab Bar in iPhone SDK

In iPhone application, you can change the background of tab bar by an image by following this code:

// customize the tab bar background
CGRect frame = CGRectMake(0, 0, 480, 49);
UIView *viewBackround = [[UIView alloc] initWithFrame:frame];
UIImage *imgBackground = [UIImage imageNamed:@"bg_tabbarview.png"];
UIColor *colorPattern = [[UIColor alloc] initWithPatternImage:imgBackground];
viewBackround.backgroundColor = colorPattern;
[colorPattern release];
[[self.tabBarController tabBar] insertSubview:viewBackround atIndex:0];
[viewBackround release];
// end custom tab bar

 

Read More

How to open xls file in iphone application?

How to open xls file in iphone application?

You can follow theres step to view a XLS file in iPhone application:

1. Add a local xls file in to your project

2. Drag and drop an UIWebView control on the view.

3. Connect Files owner and UIWebView Object

4. In voidDidLoad(), add:

    //Get the path where your local xls file is located
    NSString *filepath = [[NSBundle mainBundle] pathForResource:@"sample" ofType:@"xls"];
    //Now To use a local resource file in a web view you need to use NSURL fileURLWithPath:
    NSURL *url=[NSURL fileURLWithPath:filepath];
    //URL Requst Object
    NSURLRequest *requestObj=[NSURLRequest requestWithURL:url];
    //Load the request in the UIWebView.
    [preview loadRequest:requestObj];

Build and Go to see ;

Read More

Redirecting www to non-www Using .htaccess

The Apache Web server supports URL rewriting with the mod_rewrite engine. Placing custom rules in an .htaccess file lets you do all sorts of useful things to keep your URLs tidy. One really handy thing you can do for search engines and visitors is redirecting traffic from www to non-www version of your domain (and vice versa).

Some people prefer to use www.somesite.com, but some people prefer the shorter somesite.com. There isn’t really a right or wrong way to do it, but whatever you choose you can make sure all of your visitors get sent to the same place. With a few simple rules on the server you can choose from non-www to www, or redirecting from www to non-www.

If you already have a file named .htaccess on your Website you can add to it. If not, create one (yes, include the period at the beginning). Add either of the following rules and save. Replace yourdomain.com with your actual domain name.

Redirect www to non-www:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.yourdomain.com [NC]
RewriteRule ^(.*)$ http://yourdomain.com/$1 [L,R=301]

Redirect www to non-www:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^yourdomain.com [NC]
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [L,R=301]

Both of these rules send a full search engine friendly 301 HTTP redirect. They also preserve the entire URL (so yoursite.com/about redirects to www.yoursite.com/about).

Search engines can usually figure out which format is preferred, but since you’re showing the same page for www and non-www URLs it can’t hurt to be consistent about it.

Read More

Change the default main domain folder to sub-folder

Change the default main domain folder to sub-folder

Many web hosting providers, for example  BlueHost and  JustHost,  allow customers to host more than one domain from a single purchase (add-ons). Add-on domains usually point itself to a sub-folder under public_html or www. However, the main domain recognizes public_html as its root, which may lead to some development issues.  This article explains why it is good to have the main domain sitting under a sub folder and how to do code to make it in action.

The Benefits

Having main domain sitting in sub directory, it will be easy for website maintenance purpose. For example, you can make a backup/restore of files in the main domain with out interrupt the add-ons domain’s files. For example, if you have main domain under root of public_html, once you make zip to compress public_html folder, everything including add-ons’ files will be zipped and they all will be reset when you restore (you can’t restore it separately ).

Read More