我的应用中有几个屏幕看起来像这样(不是来自我的应用,在网上找到):
其中一个是实际的介绍屏幕,如上图所示,另一个将显示一些数据和一个"我同意"最后一个视图上的按钮。
在所有情况下,用户都必须在视图/视图控制器之间滑动。
我知道我可以在这样的视图控制器之间滑动: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
}
}
所以我想知道这样做的最佳/正确方法是什么:使用多个视图控制器或在同一个视图控制器中使用多个视图?或者还有其他被认为是核心的方式吗?