0

This is my previous question Add Swipe Gesture to display the next Item in the Detailed View

I have asked this question before but not sure how to update it with my progress.

I followed some suggestions but now I am stuck again.

I want to now add a swipe gesture to the destination view controller so that I can get to the next article without having to go back to the main page. I have added the following to set up the gesture as well as a function to load the items in the array.

All this data has been passed to the ViewController via segue

-(IBAction)swipeHandler:(UISwipeGestureRecognizer *)gesture{
{
    [self loadArticleForIndex:_articleListsports.count];
    NSLog(@"SWIPE");
    NSLog(@"Found %d character(s).", [_articleListsports count]);
}

- (void)loadArticleForIndex:(int)index
{
    //draw ur article or load your webview.

    if(index>0 && index <[_articleListsports count])
    {
        //self.targetURL  = selectedCell.targetURL;
        self.sdesc = self.sportsdescription.text;
        self.stitle = self.sportstitle.text;
        self.simage = self.sportsimage.image;
        self.scat = self.sportscategory.text;
        self.sdate = self.sportsdate.text;
    }
}


- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    UISwipeGestureRecognizer *recognizer;
    recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeHandler:)];
    [recognizer setDirection:UISwipeGestureRecognizerDirectionLeft];
    [[self view] addGestureRecognizer:recognizer];

    NSString *fileName = [NSString stringWithFormat:@"%@/sports.rss", [SPORTSUtil getDocumentRoot]];
    _articleListsports = [NSArray arrayWithContentsOfFile:fileName];     
}

Now I am stuck and have no clue on how to move forward. Please advise.

4

1 回答 1

0

您永远不会更改要传递的索引:

    [self loadArticleForIndex:_articleListsports.count];

所以这个例程总是会显示同一篇文章:

    - (void)loadArticleForIndex:(int)index
   {
        //draw ur article or load your webview.

        if(index>0 && index <[_articleListsports count])
        {
            //self.targetURL  = selectedCell.targetURL;
            self.sdesc = self.sportsdescription.text;
            self.stitle = self.sportstitle.text;
            self.simage = self.sportsimage.image;
            self.scat = self.sportscategory.text;
            self.sdate = self.sportsdate.text;
        }
    }

因此什么都不会改变。您需要保留某种索引并在浏览文章时增加它。

    [self loadArticleForIndex:currentIndex++];
于 2013-09-06T01:15:32.617 回答