Saturday 26 May 2012

UISwipeGestureRecognizer swipe multiple views in iphone sdk

- (void)viewDidLoad
{
    [super viewDidLoad];
    appDel = (AppDelegate*)[[UIApplication sharedApplication]delegate];
    appDel.IsCenter = TRUE;
    firstView = [[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil];
    secondView = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
   
   
    UISwipeGestureRecognizer *leftSwipe  =  [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(leftSwipe:)];
    [leftSwipe setDirection:(UISwipeGestureRecognizerDirectionUp)];
    leftSwipe.delegate  =   self;
    [self.view addGestureRecognizer:leftSwipe];
    [leftSwipe release];
   
    UISwipeGestureRecognizer *rightSwipe  =  [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(rightSwipe:)];
    [rightSwipe setDirection:(UISwipeGestureRecognizerDirectionDown)];
    rightSwipe.delegate   =   self;
    [self.view addGestureRecognizer:rightSwipe];
    [rightSwipe release];


    // Do any additional setup after loading the view, typically from a nib.
}
- (void)leftSwipe:(UISwipeGestureRecognizer *)recognizer
{
           if (appDel.IsCenter == TRUE) {
               CATransition *transition = [CATransition animation];
               transition.duration = 0.75;
               transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
               transition.type = kCATransitionPush;
               transition.subtype =kCATransitionFromTop;
               transition.delegate = self;
               [self.view.layer addAnimation:transition forKey:nil];
             [self.view addSubview:firstView.view];
            appDel.IsCenter = FALSE;
        }
        else {
            [secondView.view removeFromSuperview];
            appDel.IsCenter = TRUE;
        }
  
}
- (void)rightSwipe:(UISwipeGestureRecognizer *)recognizer
{
        if (appDel.IsCenter == TRUE) {
            CATransition *transition = [CATransition animation];
            transition.duration = 0.75;
            transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
            transition.type = kCATransitionPush;
            transition.subtype =kCATransitionFromBottom;
            transition.delegate = self;
           
            [self.view.layer addAnimation:transition forKey:nil];
           
             [self.view addSubview:secondView.view];
            appDel.IsCenter = FALSE;
        }
        else {
            [firstView.view removeFromSuperview];
            appDel.IsCenter = TRUE;
      
    }
}
My Facebook

Friday 25 May 2012

UIImagePickerController in iphone sdk

 -(IBAction)btnPickerClicked(id)sender{
if([UIImagePickerController isSourceTypeAvailable:
            UIImagePickerControllerSourceTypePhotoLibrary])
        {
            UIImagePickerController *picker= [[UIImagePickerController alloc]init];
            picker.delegate = self;
            picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
            [self presentModalViewController:picker animated:YES];
            [picker release];
        }
}
-(void)imagePickerController:(UIImagePickerController *)picker
      didFinishPickingImage : (UIImage *)image
                 editingInfo:(NSDictionary *)editingInfo
{
    imgView.image = image;
    [picker dismissModalViewControllerAnimated:YES];
}
-(void)imagePickerControllerDidCancel:(UIImagePickerController *) picker
{
    [picker dismissModalViewControllerAnimated:YES];
}

UIActionSheet in iphone sdk

-(IBAction)btnChooseClicked:(id)sender{
    UIActionSheet *popupQuery = [[UIActionSheet alloc] initWithTitle:@"Title" delegate:self cancelButtonTitle:@"Cancel Button" destructiveButtonTitle:nil otherButtonTitles:@"Gallary", @"Camera", nil];
    popupQuery.actionSheetStyle = UIActionSheetStyleBlackOpaque;
    [popupQuery showInView:self.view];
    [popupQuery release];
}
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
    if (buttonIndex == 0) {
        if([UIImagePickerController isSourceTypeAvailable:
            UIImagePickerControllerSourceTypePhotoLibrary])
        {
            UIImagePickerController *picker= [[UIImagePickerController alloc]init];
            picker.delegate = self;
            picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
            [self presentModalViewController:picker animated:YES];
            [picker release];
        }
    }
    else if (buttonIndex == 1) {
       
    }
    else if (buttonIndex == 2) {
       
    }
    else if (buttonIndex == 3) {
       
    }
}

Thursday 24 May 2012

For changing the color of the UITabBar in iphone

[[UITabBar appearance] setTintColor:[UIColor redColor]];

For changing the color of the UITabBarItem text in iphone


[[UITabBarItem appearance] setTitleTextAttributes:
     [NSDictionary dictionaryWithObjectsAndKeys:
      [UIColor blackColor], UITextAttributeTextColor,
      [UIColor grayColor], UITextAttributeTextShadowColor,
      [NSValue valueWithUIOffset:UIOffsetMake(0, 1)], UITextAttributeTextShadowOffset,
      [UIFont fontWithName:@"AmericanTypewriter" size:0.0], UITextAttributeFont,
      nil]
                                             forState:UIControlStateNormal];

Different types of animation in iphone sdk

http://www.cimgf.com/2012/01/11/handling-incoming-json-redux/

Different Kind Of example in iphone sdk

http://highwaystech.com/index.php/source-code/ios.html

Call example code in iphone sdk

-(IBAction)btnCallClicked:(id)sender{
   
    NSLog(@"%@",[[CategoryArray objectAtIndex:0]valueForKey:@"r_phone"] );
    NSString *strPhoneNumber = [NSString stringWithFormat:@"tel://%@",[[CategoryArray objectAtIndex:0]valueForKey:@"r_phone"] ];
    //[[UIApplication sharedApplication] openURL:[NSURL URLWithString:
    //strPhoneNumber]];
    NSURL *url= [NSURL URLWithString:strPhoneNumber];
    NSString *osVersion = [[UIDevice currentDevice] systemVersion];
   
    if ([osVersion floatValue] >= 3.1) {
        UIWebView *webview = [[UIWebView alloc] initWithFrame:[UIScreen mainScreen].applicationFrame];
        [webview loadRequest:[NSURLRequest requestWithURL:url]];
        webview.hidden = YES;
        // Assume we are in a view controller and have access to self.view
        [self.view addSubview:webview];
        [webview release];
        } else {
            // On 3.0 and below, dial as usual
            [[UIApplication sharedApplication] openURL: url];
            }
}

Push Notification in iphone sdk

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [NSThread sleepForTimeInterval:5.0];
    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
   
    self.viewController = [[[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil] autorelease];
   
    [self.window addSubview:navControll.view];
    [self.window makeKeyAndVisible];
   
    NSLog(@"Initiating remoteNoticationssAreActive");
    // / Let the device know we want to receive push notifications
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
         (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
   
    // UIRemoteNotificationType enabledTypes = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
    //[self sendProviderDeviceToken];
    NSLog(@"%@",[[[launchOptions objectForKey:@"UIApplicationLaunchOptionsRemoteNotificationKey"] objectForKey:@"aps"] objectForKey:@"alert"]);
   
   
    return YES;
}
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController {
    //NSLog(@"selected is %@",viewController);
   
    if(tabBarController.selectedViewController)
    {
        NSLog(@"selected is %@",tabBarController.selectedViewController);
    }
   
   
    NSArray *vc= tabBarController.viewControllers;
    for (int i = 0; i < [vc count]; i++) {
        UINavigationController *nc = [vc objectAtIndex:i];
        if (nc == tabBarController.selectedViewController) {
            continue;
        }
        [nc popToRootViewControllerAnimated:NO];
    }
}
- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
   
    NSString *str = [NSString
                        stringWithFormat:@"Device Token=%@",deviceToken];
    NSLog(@"%@",str);
   
    str = [[[deviceToken description]
              stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@""]]
              stringByReplacingOccurrencesOfString:@" " withString:@""];;
    NSLog(@"Device Token : %@", str);
    ///c7dc86e8376a46825c98a7d4aa48c8d46d43025798ee2ac85fe97b47488c4a88
    NSLog(@"Remote type : %d", [[UIApplication sharedApplication] enabledRemoteNotificationTypes]);
   
   
}

- (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)err {
   
    NSString *str = [NSString stringWithFormat: @"Error: %@", err];
    NSLog(@"%@",str);
   
}

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
   
    // for (id key in userInfo) {
    // NSLog(@"key: %@, value: %@", key, [userInfo objectForKey:key]);
    // }
    NSLog(@"Received Notification");
    NSLog(@"remote notification: %@",[userInfo description]);
    NSDictionary *apsInfo = [userInfo objectForKey:@"aps"];
   
    NSString *alert = [apsInfo objectForKey:@"alert"];
    NSLog(@"Received Push Alert: %@", alert);
   
    NSString *sound = [apsInfo objectForKey:@"sound"];
    NSLog(@"Received Push Sound: %@", sound);
   
    NSString *badge = [apsInfo objectForKey:@"badge"];
    NSLog(@"Received Push Badge: %@", badge);
    application.applicationIconBadgeNumber = [[apsInfo objectForKey:@"badge"] integerValue];
   
   
}

Monday 21 May 2012

how to draw line in iphone sdk

////////////////    in .h file   ///////////

CGPoint lastPoint;
    IBOutlet UIImageView *drawImage;
    BOOL mouseSwiped;   
    int mouseMoved;
    UIImageView *currentImage;

}


-(IBAction)eraseButton:(id)sender;
-(IBAction)saveButton:(id)sender;



//////////////    in .m fiel    ///////////


- (void)viewDidLoad
{
    [super viewDidLoad];
    drawImage = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 350)];
    drawImage.image = [UIImage imageNamed:@"splash.png"];
    [self.view addSubview:drawImage];
    //[drawImage addSubview:frontImage];
    self.view.backgroundColor = [UIColor lightGrayColor];
    mouseMoved = 0;
    mouseSwiped = YES;

   
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
   
    mouseSwiped = NO;
    UITouch *touch = [touches anyObject];
   
//    if ([touch tapCount] == 2) {
//        drawImage.image = [UIImage imageNamed:@"splash.png"];
//        return;
//    }
   
    lastPoint = [touch locationInView:self.view];
    lastPoint.y -= 20;
   
}

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    mouseSwiped = YES;
   
    UITouch *touch = [touches anyObject];
    CGPoint currentPoint = [touch locationInView:self.view];
    currentPoint.y -= 20;
   
   
    UIGraphicsBeginImageContext(self.view.frame.size);
    [drawImage.image drawInRect:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
    CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
    CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 5.0);
    CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 1.0, 0.0, 0.0, 1.0);
    CGContextBeginPath(UIGraphicsGetCurrentContext());
    CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
    CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y);
    CGContextStrokePath(UIGraphicsGetCurrentContext());
    drawImage.image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    [drawImage addSubview:currentImage];
   
    lastPoint = currentPoint;
   
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
   
//    UITouch *touch = [touches anyObject];
//   
//    if ([touch tapCount] == 2) {
//        drawImage.image = [UIImage imageNamed:@"splash.png"];
//        return;
//    }
   
   
    if(!mouseSwiped) {
        UIGraphicsBeginImageContext(self.view.frame.size);
        [drawImage.image drawInRect:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
        CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
        CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 5.0);
        CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 1.0, 0.0, 0.0, 1.0);
        CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
        CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
        CGContextStrokePath(UIGraphicsGetCurrentContext());
        CGContextFlush(UIGraphicsGetCurrentContext());
        drawImage.image = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();
    }
}

-(IBAction)eraseButton:(id)sender{
    drawImage.image = [UIImage imageNamed:@"splash.png"];
}
-(IBAction)saveButton:(id)sender{
    UIImage *image = drawImage.image;
    NSData *imageData = UIImagePNGRepresentation(image); 
    NSFileManager *fileManager = [NSFileManager defaultManager]; 
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
    NSString *documentsDirectory = [paths objectAtIndex:0]; 
    NSString *fullPath = [documentsDirectory stringByAppendingPathComponent: 
                          [NSString stringWithFormat:@"%@.png", drawImage.image]]; 
   
    [fileManager createFileAtPath:fullPath contents:imageData attributes:nil]; 
    NSLog(@"image saved"); 
   

}

GestureRecognize example iphone

http://www.icodeblog.com/2010/10/14/working-with-uigesturerecognizers/

iphone example demos

http://www.stanford.edu/class/cs193p/cgi-bin/drupal/downloads-2010-winter

Sunday 20 May 2012

how to use automasking in iphone sdk

-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
        if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) {
            // UIImage *titleImage = [UIImage imageNamed:@"nav-l"];
            // UIImage *joinImage = [UIImage imageNamed:@"join-port"];
            self.navigationController.title = @"news";
            self.navigationController.navigationBar.tintColor = [UIColor clearColor];
            // [self.navigationController.navigationBar setBackgroundImage:titleImage forBarMetrics:UIBarMetricsDefault];
            //  self.navigationController.view.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"nav-l.png"]];
            [self.navigationController.navigationBar setNeedsDisplay];
            //   navimg.image=titleImage;
            //   joinimg.image=joinImage;
           
        } else {
            //   UIImage *titleImage = [UIImage imageNamed:@"nav-p"];
            //    UIImage *joinImage = [UIImage imageNamed:@"join-land"];
            self.navigationController.navigationBar.tintColor = [UIColor clearColor];
            //    [self.navigationController.navigationBar setBackgroundImage:titleImage forBarMetrics:UIBarMetricsDefault];
            // self.navigationController.view.backgroundColor = [[UIColor alloc] initWithPatternImage:[UIImage imageNamed:@"nav-p.png"]];
            [self.navigationController.navigationBar setNeedsDisplay];
            //   navimg.image=titleImage;
            //   joinimg.image = joinImage;
        }
    }
}

cocos2D examples to learn

http://www.cocos2d-iphone.org/wiki/doku.php/prog_guide:index

Saturday 19 May 2012

how to compare two dates with using NSUserDefaults in iphone sdk

 NSDateFormatter *df= [[NSDateFormatter alloc] init];
   
    [df setDateFormat:@"yyyy-MM-dd"];
   
    NSDate *dt1 = [[NSDate alloc] init];
   
    dt1=[df dateFromString:@"2012-06-25"];
   
   
    [[NSUserDefaults standardUserDefaults] setObject:dt1 forKey:@"myDateKey"];
  

    NSDate *myDate = (NSDate *)[[NSUserDefaults standardUserDefaults] objectForKey:@"myDateKey"];
    NSLog(@"%@",myDate);
   
    NSDate *currDate = [NSDate date];
    NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
    [dateFormat setDateFormat:@"dd/MM/yyyy"];

   
    NSLog(@"%@",currDate);
   
    NSComparisonResult result = [currDate compare:myDate];
   
    switch (result)
   
    {
           
        case NSOrderedAscending:
            NSLog(@"%@ is greater than %@", myDate, currDate);
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Message" message:@"%@ is greater than %@" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
            [alert show];
            [alert release];
            break;
           
        case NSOrderedDescending:
            NSLog(@"%@ is less %@", myDate, currDate);
            UIAlertView *alert1 = [[UIAlertView alloc] initWithTitle:@"Message" message:@"%@ is less than %@" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
            [alert1 show];
            [alert1 release];
            break;
           
        case NSOrderedSame:
            NSLog(@"%@ is equal to %@", myDate, currDate);
            UIAlertView *alert2 = [[UIAlertView alloc] initWithTitle:@"Message" message:@"%@ is equal to %@" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
            [alert2 show];
            [alert2 release];
            break;
         
           
        default:
            NSLog(@"erorr dates %@, %@", myDate, currDate);
            UIAlertView *alert3 = [[UIAlertView alloc] initWithTitle:@"Message" message:@"error dates %@, %@" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
            [alert3 show];
            [alert3 release];
            break;
    }

Username and Password authentication..how to retrive data from server in iphone sdk


 //////////////////// in .h file //////////

IBOutlet UITextField *txtUser;
    IBOutlet UITextField *txtPass;
    IBOutlet UILabel *lblMsg;
    NSMutableData *webData; 

 \\\\\\\\\\\\\\\\\\\\  in . m file  ////////////////////////////////

-(IBAction)btnLoginClicked:(id)sender{
    NSString *strUserName = txtUser.text;
    NSString *strPassword = txtPass.text;
   
    if ([strUserName isEqualToString:@""] || [strPassword isEqualToString:@""]) {
        lblMsg.text = @"Input your Value";
        [txtPass resignFirstResponder];
        [txtUser resignFirstResponder];
    }
   
    NSString *post = [[NSString alloc] initWithFormat:@"log=%@&pwd=%@",strUserName,strPassword];
    NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
    NSString *postLength = [NSString stringWithFormat:@"",[postData length]];
    NSURL *url = [NSURL URLWithString:@"http://ideaact.neonexusdemo.com/wp-content/themes/idea/andr.php"];
    NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url];
    [theRequest setHTTPMethod:@"POST"];
    [theRequest setValue:postLength forHTTPHeaderField:@"Content-Length"];
    [theRequest setHTTPBody:postData];
    NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
    if (theConnection) {
        webData = [[NSMutableData data] retain];
    }
    else {
       
    }
   
    [txtUser resignFirstResponder];
    [txtPass resignFirstResponder];
    txtUser.text = nil;
    txtPass.text = nil;
   
}

-(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
    [webData setLength: 0];
}
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
   
   
    [webData appendData:data];
}
-(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
   
    [connection release];
    [webData release];
}
-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
   
    NSString *loginStatus = [[NSString alloc] initWithBytes: [webData mutableBytes] length:[webData length] encoding:NSUTF8StringEncoding];
    NSLog(@"%@",loginStatus);
    lblMsg.text = loginStatus;
    [loginStatus release];
   
   
   
    [connection release];
    [webData release];
}

Friday 18 May 2012

how to make TabBar in iphone sdk

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.navigationController.navigationBarHidden = YES;
   
    imgBackground.image =[UIImage imageNamed:@"splash.png"];
   
    appDel = (AppDelegate*)[[UIApplication sharedApplication] delegate];
   
    tab=[[UITabBar alloc]initWithFrame:CGRectMake(0.0, 412,self.view.bounds.size.width, 49.0)];
    tab.delegate=self;
   
    [self.view addSubview:tab];
    [self createTabBarItems];
   

    // Do any additional setup after loading the view, typically from a nib.
}

- (void)createTabBarItems{   
   
      tbEvent =[[UITabBarItem alloc] initWithTitle:@"Event" image:[UIImage imageNamed:@"latest.png"] tag:0];
   
    tbAbout = [[UITabBarItem alloc] initWithTitle:@"AboutUs" image:[UIImage imageNamed:@"about.png"] tag:1];
   
    tbContact = [[UITabBarItem alloc] initWithTitle:@"ContactUs" image:[UIImage imageNamed:@"contact.png"] tag:2];
   
    tab.items =[[NSArray arrayWithObjects:tbEvent,tbAbout,tbContact,nil] retain];
   
    [self.view addSubview:tab];
   
    [tab release];
   
}

- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item{
   
    //    if(tabBar.selectedItem.tag == 0)
    //    {
    //        self.tab.selectedItem = tbHome;
    //   
    //    }
    if(tabBar.selectedItem.tag == 0)
    {
       // appDel.activityView.hidden = NO;
        EventViewController *eventView = [[EventViewController alloc] initWithNibName:@"EventViewController" bundle:nil];
        [self.navigationController pushViewController:eventView animated:NO];
        [eventView release];
    }
    if (tabBar.selectedItem.tag == 1) {
       
        AboutUsViewController *aboutView = [[AboutUsViewController alloc] initWithNibName:@"AboutUsViewController" bundle:nil];
        [self.navigationController pushViewController:aboutView animated:NO];
        [aboutView release];
    }
    if (tabBar.selectedItem.tag == 2) {
        ContactUsViewController *contactView = [[ContactUsViewController alloc] initWithNibName:@"ContactUsViewController" bundle:nil];
        [self.navigationController pushViewController:contactView animated:NO];
        [contactView release];
    }
   
}

how to make custom tabBar in appDel

// Override point for customization after application launch.
    UIViewController *viewController1 = [[[FirstViewController alloc] initWithNibName:@"FirstViewController" bundle:nil] autorelease];
    UIViewController *viewController2 = [[[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil] autorelease];
    UIViewController *viewController3 = [[[join alloc] initWithNibName:@"join" bundle:nil] autorelease];
    UIViewController *viewController4 = [[[shop alloc] initWithNibName:@"shop" bundle:nil] autorelease];
    UIViewController *viewController5 = [[[News alloc] initWithNibName:@"News" bundle:nil] autorelease];
   
    self.tabBarController = [[[UITabBarController alloc] init] autorelease];
    self.tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2,viewController3,viewController4,viewController5, nil];
    self.window.rootViewController = self.tabBarController;
    [self.window makeKeyAndVisible];
    return YES;

how to make custom label in iphone sdk

UILabel *lblDetail = [[UILabel alloc] initWithFrame:CGRectMake(85, 30, 165, 20)];
    lblDetail.text = [[CategoryArray objectAtIndex:indexPath.row] valueForKey:@"s_desc"];
    lblDetail.textAlignment = UITextAlignmentLeft;
    lblDetail.textColor = [UIColor grayColor];
    lblDetail.backgroundColor = [UIColor clearColor];
    lblDetail.font = [UIFont fontWithName:@"Verdana" size:10];
    lblDetail.numberOfLines=0;
    lblDetail.lineBreakMode = UILineBreakModeTailTruncation;
    [cell addSubview:lblDetail];
    [lblDetail release];

how to create custom button in iphone sdk

detailsButton = [UIButton buttonWithType:UIButtonTypeCustom];
    detailsButtonImage = [UIImage imageNamed:@"read-more.png"];
    [detailsButton setBackgroundImage:detailsButtonImage forState:UIControlStateNormal];
    detailsButton.frame = CGRectMake(250, 40, 60, 30);
    detailsButton.tag = indexPath.row;
    [detailsButton addTarget:self action:@selector(ShowDetails:) forControlEvents:UIControlEventTouchUpInside];
    NSLog(@"%d", detailsButton.tag);









-(IBAction)ShowDetails:(id)sender{
//code here
}

how to consume webservice in iphone sdk

in .h file to define this////////////////////////

 NSMutableData *webData;
    NSMutableString *soapResults;
    NSURLConnection *conn;
    NSMutableArray *CategoryArray;
    NSMutableString *currentElementValue;
    IBOutlet UITableView *tblView;
    Category *aCategory;
    NSMutableDictionary *dictTemp;
    NSXMLParser *xmlParser;
    bool elementFound;



in .m file define this//////////////////////////

- (void)viewDidLoad
{
    [super viewDidLoad];
    tblView.delegate = self;
    tblView.dataSource = self;
   
    if(![CategoryArray count]>0 ){
        [self connectToWebService];
    }
    tblView.backgroundColor = [UIColor whiteColor];
    [self.view setBackgroundColor:[UIColor whiteColor]];
    [tblView setSeparatorColor:[UIColor grayColor]];

    // Do any additional setup after loading the view from its nib.
}


-(void)connectToWebService{
   
    // [NSThread detachNewThreadSelector:@selector(ShowActivity) toTarget:self withObject:nil];
   
    NSString *strUrl = [NSString stringWithFormat:@"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
                        "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"
                        "<soap:Body>"
                        "<GetNews xmlns=\"http://tempuri.org/\" />"
                        "</soap:Body>"
                        "</soap:Envelope>"];
   
    NSURL *url = [NSURL URLWithString:
                  @"http://tgm.ourappadmin.com/tgm.asmx"];
    NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url];
   
    NSString *msgLength = [NSString stringWithFormat:@"%d",[strUrl length]];
    [req addValue:@"text/xml; charset=utf-8"
forHTTPHeaderField:@"Content-Type"];
    [req addValue:@"http://tempuri.org/GetNews"
forHTTPHeaderField:@"SOAPAction"];
    [req addValue:msgLength forHTTPHeaderField:@"Content-Length"];
   
    [req setHTTPMethod:@"POST"];
    [req setHTTPBody: [strUrl dataUsingEncoding:NSUTF8StringEncoding]];
   
    conn = [[NSURLConnection alloc] initWithRequest:req delegate:self];
    if (conn) {
       
        webData = [[NSMutableData data] retain];
    }  
   
}

-(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
    [webData setLength: 0];
}
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
    [webData appendData:data];
}
-(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
   
    //[appDel.HUD hide:YES];
   
    UIAlertView *av = [[UIAlertView alloc] initWithTitle:@"Alert!!!" message:@"Make sure that you are connected to the Internet." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [av show];
    [av release];
    [connection release];
    [webData release];
}
-(void)connectionDidFinishLoading:(NSURLConnection *)connection {
    if(xmlParser != nil && [xmlParser retainCount] > 0)
    {
        [xmlParser release]; xmlParser = nil;
    }
    xmlParser = [[NSXMLParser alloc] initWithData: webData];
    [xmlParser setDelegate: self];
    [xmlParser setShouldResolveExternalEntities: YES];
    // [appDel.HUD hide:YES];
    [xmlParser parse];
    [connection release];
    [webData release];
}

#pragma mark -
#pragma mark NSXMLParser methods
-(void)parser:(NSXMLParser*)parser
didStartElement:(NSString*)elementName
 namespaceURI:(NSString*)namespaceURI
qualifiedName:(NSString*)qualifiedName
   attributes:(NSDictionary*)attributeDict
{
    NSLog(@"element : %@",elementName);
   
    if([elementName isEqualToString:@"GetNewsResult"])
    {
       
        CategoryArray=[[NSMutableArray alloc]init];
       
    }
    else if([elementName isEqualToString:@"Pro_Master_ToolforMobile"])
    {
       
        if(dictTemp != nil && [dictTemp retainCount] > 0) {
           
            [dictTemp release];
            dictTemp = nil;
           
        }
        dictTemp = [[NSMutableDictionary alloc] init];
    }
}

-(void)parser:(NSXMLParser*)parser
foundCharacters:(NSString*)string
{
   
    if(!currentElementValue)
    {
        currentElementValue=[[NSMutableString alloc] initWithString:string];
    }
    else
    {
        [currentElementValue appendString:string];
    }
}
-(void)parser:(NSXMLParser*)parser
didEndElement:(NSString*)elementName
 namespaceURI:(NSString*)namespaceURI
qualifiedName:(NSString*)qualifiedName
{
    NSLog(@"%@",elementName);
    // if end of root element is found- i.e. end of your xml file.
    if ([elementName isEqualToString:@"a_id"] || [elementName isEqualToString:@"a_title"] || [elementName isEqualToString:@"a_desc"]) {
       
        [dictTemp setObject:currentElementValue forKey:elementName];
       
    }   
    else if([elementName isEqualToString:@"Pro_Master_ToolforMobile"])
    {
        [CategoryArray addObject:dictTemp];
        if(dictTemp != nil && [dictTemp retainCount] > 0)
        {
            [dictTemp release];
            dictTemp = nil;
        }
       
    }
    // [categoryTable reloadData];
    //[aCategory setValue:currentElementValue forKey:elementName];
   
    [currentElementValue release];
    currentElementValue=nil;
   
    NSLog(@"arr detail %@",CategoryArray);
}
- (void)parserDidEndDocument:(NSXMLParser *)parser{
   
    NSLog(@"Arr Detail : %@", CategoryArray);
    NSString *strPhone = [[NSString alloc] initWithFormat:@"%@",[[CategoryArray objectAtIndex:0] valueForKey:@"a_title"]];
    NSLog(@"%@",strPhone);
   
    if([CategoryArray count] > 0) {
       
        [tblView reloadData];
       
    }
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
   
    return [CategoryArray count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    // UIImage *detailsButtonImage;
   
    static NSString *CellIdentifier = @"Cell";
   
   
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    cell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    cell.selectionStyle = NO;
    //   cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
   
    UILabel *lbl = [[UILabel alloc] initWithFrame:CGRectMake(5, 8, 235, 20)];
    lbl.text = [[CategoryArray objectAtIndex:indexPath.row] valueForKey:@"a_title"];
    lbl.textAlignment = UITextAlignmentLeft;
    lbl.textColor = [UIColor redColor];
    lbl.backgroundColor = [UIColor clearColor];
    lbl.font = [UIFont fontWithName:@"Verdana-Bold" size:13];
    lbl.numberOfLines=0;
    lbl.lineBreakMode = UILineBreakModeWordWrap;
    [cell addSubview:lbl];
    [lbl release];
   
   
    UILabel *lblDetail = [[UILabel alloc] initWithFrame:CGRectMake(5, 30, 165, 20)];
    lblDetail.text = [[CategoryArray objectAtIndex:indexPath.row] valueForKey:@"a_desc"];
    lblDetail.textAlignment = UITextAlignmentLeft;
    lblDetail.textColor = [UIColor grayColor];
    lblDetail.backgroundColor = [UIColor clearColor];
    lblDetail.font = [UIFont fontWithName:@"Verdana" size:10];
    lblDetail.numberOfLines=0;
    lblDetail.lineBreakMode = UILineBreakModeTailTruncation;
    [cell addSubview:lblDetail];
    [lblDetail release];
   
   
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 80;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    NSString *str = [[CategoryArray objectAtIndex:indexPath.row] valueForKey:@"a_desc"];
    NSString *strLabel = [[CategoryArray objectAtIndex:indexPath.row] valueForKey:@"a_title"];
    NewsDetail *newsDetail = [[NewsDetail alloc] initWithNibName:@"NewsDetail" bundle:nil];
    newsDetail.strPass=str;
    newsDetail.strLabel= strLabel;
    [self presentModalViewController:newsDetail animated:YES];
    [newsDetail release];
}