【问题标题】:Horizontal scroll infinite view水平滚动无限视图
【发布时间】:2013-01-01 19:48:43
【问题描述】:
我正在创建一个新闻应用程序。要求就是这样。
- 显示新闻的列表。用户可以拉取最新的新闻列表。
- 当用户选择一条新闻时,它将导航到详细视图。
- 在详细视图中。用户可以滑动手指导航到下一个或上一个新闻。
对于要求 1,2。有很多解决方案。这很容易。
但是对于要求3。我觉得有点难。假设我们有一个包含 10 条新闻的列表。
我选择第二条新闻以进入其详细视图。如果我从左向右滑动手指,它将导航到第一个新闻视图。当我再次从左向右滑动时。它应该访问该服务以查看是否有可用的最新消息。如果是,那么它应该浏览最新消息。
我想知道有没有第三方项目在做这个逻辑?
感谢任何 cmets!
【问题讨论】:
标签:
ios
scrollview
slide
infinite
【解决方案1】:
我不认为有任何特定的逻辑。你必须自己创建逻辑。
对于要求 1 和 2,您可以使用它来列出最新消息 -> RevealViewController
对于需求 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 的逻辑..希望这会有所帮助..