0

I have got an array of four tablecells, the first when pressed should call a 'compose tweet function', the second, facebook, the third open youtube and the last 'compose' email. I am in a pickle on this one because I am not sure of how to call each button separately. Here is my code to 'implement the compose tweet function'

-(void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath


{
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter])
{
    SLComposeViewController *tweetSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];
    [tweetSheet setInitialText:@"@SybreLabs"];
}


}
@end

let me know what you all think, please i am new to coding

animuson
  • 53,861
  • 28
  • 137
  • 147
DanKiiing
  • 102
  • 1
  • 11
  • Please read [this guide](http://developer.apple.com/library/ios/#documentation/userexperience/conceptual/tableview_iphone/AboutTableViewsiPhone/AboutTableViewsiPhone.html) about UITableViews. – KDaker Oct 18 '12 at 07:32

1 Answers1

0

For your UITableView (assuming you're using one), you can identify which cell was tapped using the UITableView delegate method:

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    switch case([indexPath row])
    {
        case 1:
            // do facebook action
            break;
        case 2:
            // do twitter action
            break;
        case 3:
            // do email action
            break;
        case 4:
            // do youtube action
            break;  
    }
}

Here's the reference method by Apple:

http://developer.apple.com/library/ios/#documentation/uikit/reference/UITableViewDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intfm/UITableViewDelegate/tableView:didSelectRowAtIndexPath:

Zhang
  • 11,549
  • 7
  • 57
  • 87