Popular Posts

Jun 28, 2011

Label code For iPhone


 

        UILabel *myLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 110, 100)];
         myLabel.text = @"Lorem...";
         [self.view addSubview:myLabel];
        
         myLabel.backgroundColor = [UIColor clearColor]; // [UIColor brownColor];
        myLabel.font = [UIFont fontWithName:@"Zapfino" size: 14.0];
         myLabel.shadowColor = [UIColor grayColor];
         myLabel.shadowOffset = CGSizeMake(1,1);
         myLabel.textColor = [UIColor blueColor];
        myLabel.textAlignment = UITextAlignmentRight; // UITextAlignmentCenter, UITextAlignmentLeft
        
         myLabel.lineBreakMode = UILineBreakModeWordWrap;
         myLabel.numberOfLines = 2; // 2 lines ; 0 - dynamical number of lines
         myLabel.text = @"Lorem ipsum dolor sit\namet...";

Jun 19, 2011

Rotate the Screen (iPhone)



- Create a view based project. say Rotations…
- Type the code to RotationsAppDelegate.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {   
   
         [[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeLeft];

    // Override point for customization after app launch   
    [window addSubview:viewController.view];
    [window makeKeyAndVisible];

         return YES;
}



[[UIDevice currentDevice]   setOrientation:UIInterfaceOrientationLandscapeLeft];

- You can get more option by clicking right button.. then jump to Defination.

typedef enum {
    UIInterfaceOrientationPortrait           = UIDeviceOrientationPortrait,
    UIInterfaceOrientationPortraitUpsideDown = UIDeviceOrientationPortraitUpsideDown,
    UIInterfaceOrientationLandscapeLeft      = UIDeviceOrientationLandscapeRight,
    UIInterfaceOrientationLandscapeRight     = UIDeviceOrientationLandscapeLeft
} UIInterfaceOrientation;

Jun 13, 2011

Add Navigation Controller



-Take a window based project.Open AppDelegate.h file and            
-Write this code to interface.
UINavigationController     *navController;

-Before the @end write the property. 
@property (nonatomic, retain) IBOutlet UINavigationController *navController;

-Synthesize to implementation file.
@synthesize navController

-Now write the code to application didFinishLaunchingWithOptions

         iBlowViewController *mainViewController = [[iBlowViewController alloc] initWithNibName:@"iBlowViewController" bundle:nil];
         UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:mainViewController];
         self.navController = navigationController;
         [navigationController release];
        
// Configure and display the window.
         [window addSubview:navController.view];
         [window makeKeyAndVisible];

Change Status Bar Style


Type this code to  viewdidload function.

[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleBlackOpaque;
         self.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;

You can find more options by right click and select on the Go to Definition option.
    UIBarStyleDefault          = 0,
    UIBarStyleBlack            = 1,
   
    UIBarStyleBlackOpaque      = 1, // Deprecated. Use UIBarStyleBlack
    UIBarStyleBlackTranslucent = 2, // Deprecated. Use UIBarStyleBlack and set the translucent property to YES

Make Button to nav Bar


- (void)viewDidLoad
{
         // Add our custom add button as the nav bar's custom right view
         UIBarButtonItem *addButton = [[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"AddTitle", @"")
                                                                                                                                                                                       style:UIBarButtonItemStyleBordered
                                                                                                                                                                                      target:self
                                                                                                                                                                                      action:@selector(addAction:)] autorelease];
         self.navigationItem.rightBarButtonItem = addButton;
}

- (IBAction)addAction:(id)sender
{
         // The add button was clicked, handle it here
}

Open Grouped table view


Change the table style to Grouped
BlowRecordsTableViewController *blowRecords = [[BlowRecordsTableViewController alloc] initWithStyle:UITableViewStyleGrouped] ;
         [self.navigationController pushViewController:blowRecords animated:YES];
            [blowRecords release];

Enable File Hiding Option

There are some computer viruses that can hide Folder Option from the menu.
To enable the option..

- Go to start/run
- Type HKEK_CURRENT_USER\Software\Microsoft\windows\current version\Explorer\advanced option
- Then double click on hidden option.
- Change value data to 1 then click OK.
- You will get the folder option