Monday 30 January 2012

In Built Twitter use of ios5 in iphone sdk...



  1. - (IBAction)shareOnTwitter:(id)sender {
  2.    
  3.     TWTweetComposeViewController *twitter = [[TWTweetComposeViewController alloc] init];
  4.    
  5.     [twitter setInitialText:@"It's really that simple!"];
  6.     [twitter addImage:[UIImage imageNamed:@"twitter.png"]];
  7.  
  8.     [self presentViewController:twitter animated:YES completion:nil];
  9.        
  10.     twitter.completionHandler = ^(TWTweetComposeViewControllerResult res) {
  11.        
  12.         if(res == TWTweetComposeViewControllerResultDone)
  13.         {
  14.            
  15.             UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"Succes!" message:@"Your Tweet was posted succesfully" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
  16.            
  17.             [alertView show];
  18.            
  19.            
  20.         }else if(res == TWTweetComposeViewControllerResultCancelled)
  21.         {
  22.            
  23.             UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Your Tweet was not posted" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
  24.            
  25.             [alertView show];
  26.            
  27.         }
  28.        
  29.         [self dismissModalViewControllerAnimated:YES];
  30.        
  31.     };
  32.    
  33. }

No comments:

Post a Comment