UIGestureRecognizer Issue: trying to navigate backwards

Trying to make it so if the user swipes left, the app will navigate backwards. Lately the only success I've had is if I specify the UITableView; if a cell is already selected and then a swipe occurs WITHIN the cell it will navigate backwards, but that's it. I'd like to make it so the user can swipe anywhere on the screen without being confined to swiping a value in a table cell. After they've done so, the initial array menu is displayed. Any feedback? Code below:

- (void)viewDidLoad
{
    [super viewDidLoad];
    arrayNo = [[NSMutableArray alloc] init];
    [[self myTableView] setDelegate:self];
    [[self myTableView] setDataSource:self];

    UISwipeGestureRecognizer * back = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(reLoad)];
    [back setDirection:(UISwipeGestureRecognizerDirectionLeft)];
    [self.view addGestureRecognizer:back];

    if (back)
    {
        NSLog(@"SWIPED");
        NSString *arts = @"Arts and Museums";
        NSString *coffee = @"Coffee and Bakeries";
        NSString *tours = @"Tours and Festivals";
        NSString *hotels = @"Hotels and Inns";
        NSString *leisure = @"Leisure and Recreation";
        NSString *music = @"Live Music";
        NSString *bars = @"Night Clubs and Bars";
        NSString *food = @"Restaurants";
        NSString *shopping = @"Shopping";
        NSString *transportation = @"Transportation";

        [arrayNo removeAllObjects];

        [arrayNo addObject:arts];
        [arrayNo addObject:coffee];
        [arrayNo addObject:tours];
        [arrayNo addObject:hotels];
        [arrayNo addObject:leisure];
        [arrayNo addObject:music];
        [arrayNo addObject:bars];
        [arrayNo addObject:food];
        [arrayNo addObject:shopping];
        [arrayNo addObject:transportation];
    }
}

Answers


I do believe I was making things too complicated. To solve, I am now using this:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];

    UISwipeGestureRecognizer * back = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(backUp1)];
    [back setDirection:(UISwipeGestureRecognizerDirectionLeft)];
    [self.view addGestureRecognizer:back];

    if ([cell.textLabel.text isEqualToString: @"Arts and Museums"])
    {        
        NSString *galleries = @"Art Galleries";
        NSString *dramatic = @"Dramatic Arts";
        NSString *museums = @"Museums";

        [arrayNo removeAllObjects];

        [arrayNo addObject:galleries];
        [arrayNo addObject:dramatic];
        [arrayNo addObject:museums];

        [self.myTableView reloadData];
    }
}

-(void)backUp1
{
    NSLog(@"SWIPED");
    NSString *arts = @"Arts and Museums";
    NSString *coffee = @"Coffee and Bakeries";
    NSString *tours = @"Tours and Festivals";
    NSString *hotels = @"Hotels and Inns";
    NSString *leisure = @"Leisure and Recreation";
    NSString *music = @"Live Music";
    NSString *bars = @"Night Clubs and Bars";
    NSString *food = @"Restaurants";
    NSString *shopping = @"Shopping";
    NSString *transportation = @"Transportation";

    [arrayNo removeAllObjects];

    [arrayNo addObject:arts];
    [arrayNo addObject:coffee];
    [arrayNo addObject:tours];
    [arrayNo addObject:hotels];
    [arrayNo addObject:leisure];
    [arrayNo addObject:music];
    [arrayNo addObject:bars];
    [arrayNo addObject:food];
    [arrayNo addObject:shopping];
    [arrayNo addObject:transportation];

    [self.myTableView reloadData];
}

Need Your Help

access dictionary with unicode keys from django template

unicode django-templates

I have a dictionary with unicode keys (the dictionary is being pulled from a mongo db). when i render it in a template, i cant access it using the keys since there is no way to generate unicode str...

Calling std::sort

c++ sorting std

sort in the C++ standard library is called as:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.