【发布时间】:2017-10-06 02:30:27
【问题描述】:
我的应用中有几个屏幕看起来像这样(不是来自我的应用,是在网上找到的):
其中一个是实际的介绍屏幕,就像上面的那个,另一个会在最后一个视图上显示一些数据和一个“我同意”按钮。
在所有情况下,用户都必须在视图/视图控制器之间滑动。
我知道我可以像这样在视图控制器之间滑动:Setting up UIScrollView to swipe between 3 view controllers,我也可以使用它在视图之间滑动:
func respondToSwipeGesture(_ gesture: UIGestureRecognizer)
{
print("respondToSwipeGesture")
if let swipeGesture = gesture as? UISwipeGestureRecognizer
{
switch swipeGesture.direction
{
case UISwipeGestureRecognizerDirection.right:
if(isLeftToRightActive == true)
{
print("Swiped right")
moveTheMainView()
}
case UISwipeGestureRecognizerDirection.left:
if(isLeftToRightActive == false)
{
print("Swiped left")
moveTheMainView()
}
default:
break
}
}
}
func moveTheMainView()
{
print("moveTheMainView")
let mainViewContainerHeight = self.vMainViewContainer.frame.height
let mainViewContainerWidth = self.vMainViewContainer.frame.width
let mainViewContainerModifiedLeft : CGFloat = mainViewContainerWidth / 2
if(isLeftToRightActive == false)
{
print("Move the main view to the right")
let urlCRTable = Bundle.main.url(forResource: "CRCharts", withExtension: "html")
let crTableRequestObj = URLRequest(url: urlCRTable!)
self.wvCRTable.loadRequest(crTableRequestObj)
ivIndicator.image = UIImage(named: "SecondOn")
isLeftToRightActive = true
}
else
{
print("Move the main view to the left")
let urlCRTable = Bundle.main.url(forResource: "CRTable", withExtension: "html")
let crTableRequestObj = URLRequest(url: urlCRTable!)
self.wvCRTable.loadRequest(crTableRequestObj)
ivIndicator.image = UIImage(named: "FirstOn")
isLeftToRightActive = false
}
}
所以我想知道最好/正确的方法是什么:使用多个视图控制器或在同一个视图控制器中使用多个视图?或者有没有其他被认为是正确的方式?
【问题讨论】:
-
我建议检查UIPageViewController
-
@AhmadF 谢谢,我去看看。
标签: ios swift uiview uiviewcontroller