Ios 水平滚动无限视图
我正在创建一个新闻应用程序。要求是Ios 水平滚动无限视图,ios,scrollview,slide,infinite,Ios,Scrollview,Slide,Infinite,我正在创建一个新闻应用程序。要求是 显示新闻的列表。用户可以拉取以获取最新的新闻列表 当用户选择一条新闻时,它将导航到详细信息视图 在详细视图中。用户可以滑动手指导航到下一条或上一条新闻 对于要求1,2。有很多解决方案。这很容易。 但是为了满足要求。我觉得有点难。假设我们有10条新闻。 我选择第二条新闻以进入其详细视图。如果我将手指从左向右滑动,它将导航到第一个新闻视图。当我再次从左向右滑动时。它应该访问该服务以查看是否有最新消息可用。如果是,则应浏览最新新闻 我想知道是否有任何第三方项目正在这
任何意见都将不胜感激 我不认为有任何具体的逻辑。。您必须自己创建逻辑 对于要求1和2,您可以使用此列表列出最新消息-> 对于要求3,您需要添加手势识别器,如swipeleft和swiperight 这只是一个例子:
- (void)viewDidLoad
{
[super viewDidLoad];
UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(tappedRightButton:)];
[swipeLeft setDirection:UISwipeGestureRecognizerDirectionLeft];
[self.view addGestureRecognizer:swipeLeft];
UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(tappedLeftButton:)];
[swipeRight setDirection:UISwipeGestureRecognizerDirectionRight];
[self.view addGestureRecognizer:swipeRight];
}
- (IBAction)tappedRightButton:(id)sender
{
NSUInteger selectedIndex = [rootVC.tabBarController selectedIndex];
[rootVC.tabBarController setSelectedIndex:selectedIndex + 1];
}
- (IBAction)tappedLeftButton:(id)sender
{
NSUInteger selectedIndex = [rootVC.tabBarController selectedIndex];
[rootVC.tabBarController setSelectedIndex:selectedIndex - 1];
}
只需相应地修改tappedRightButton和tappedLeftButton的逻辑..希望这有帮助