V
V
V2015-02-09 18:17:24
Objective-C
V, 2015-02-09 18:17:24

How to implement transition to another View Controller through SWTableViewCell?

Following the tutorial from here ( www.appcoda.com/swipeable-uitableviewcell-tutorial ), the question arose: how, for example, from the right More button to switch to another screen?
The standard code from the tutorial for showing a UIActionSheet when clicking More.

- (void)swipeableTableViewCell:(SWTableViewCell *)cell didTriggerRightUtilityButtonWithIndex:(NSInteger)index {
    switch (index) {
        case 0:
        {
            // More button is pressed
            UIActionSheet *shareActionSheet = [[UIActionSheet alloc] initWithTitle:@"Share" delegate:nil cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Share on Facebook", @"Share on Twitter", nil];
            [shareActionSheet showInView:self.view];
            [cell hideUtilityButtonsAnimated:YES];
            break;
        }
  }

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
A
An, 2015-02-09
@ermolushka

A small prelude:
If you are just learning, and iOS 7 support is not important to you, it is better to look towards the standard api
, see the tableView:editActionsForRowAtIndexPath method
An example of how to use it here , towards the end
And the transition to another "screen" is done in the simplest case

-(void)buttonizeButtonTap:(id)sender{
    [self performSegueWithIdentifier:@"Associate" sender:sender];
}

where Associate is the id of the transition in the storyboard (the string is set there directly)
The example is taken from here , you can also see screenshots with arrows there, though for the old XCode, but nothing much has changed there.

I
iQQator, 2015-03-11
@iDevPro

the question arose: how, for example, from the right More button to switch to another screen?

1) If you are using a Storyboard , drag from the far right point (approximately the location of the More button) the wires to the desired controller and select an action in the " Accessory actions " section of the menu that appears.
2) If you are using Sotryboard , but for some reason you want to handle the transition event yourself (Connected the controller to another controller with a wire). Here, according to the previous advice, only with a change:
- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath {
[self performSegueWithIdentifier:@"ShowMoreSegue" sender:nil];
}

3) If you don't want to use the Accessory button then follow the first advice :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question