If you project must handle few tableViews you can realize it exactly like this project https://github.com/gabrieltheodoropoulos/iOS-Swift-PageControl but , instead of using a UIView by using a UITableView and you can do exactly what you want..
You can customize your main viewController to add name, age and the update button by correct the scrollView frame in your storyboard, it's simple to do.
P.S. About the memory consumption, if your project is to heavy, you can think about a method to reuse the tableView variables as explained better in this stack overflow post
Here below an example how to modify all code to realize it:
class ViewController: UIViewController, UIScrollViewDelegate, UITableViewDelegate,UITableViewDataSource {
@IBOutlet weak var scrollView: UIScrollView!
@IBOutlet weak var pageControl: UIPageControl!
let totalPages = 8 // here you put your datasource array count
var currentTableView : UITableView!
let sampleBGColors: Array<UIColor> = [UIColor.redColor(), UIColor.yellowColor(), UIColor.greenColor(), UIColor.magentaColor(), UIColor.orangeColor()]
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
configureScrollView()
configurePageControl()
}
func configureScrollView() {
scrollView.pagingEnabled = true
scrollView.showsHorizontalScrollIndicator = false
scrollView.showsVerticalScrollIndicator = false
scrollView.scrollsToTop = false
scrollView.contentSize = CGSizeMake(scrollView.frame.size.width * CGFloat(totalPages), scrollView.frame.size.height)
scrollView.delegate = self
// Load the TestView view from the TestView.xib file and configure it properly.
for i in 0 ..< totalPages {
// Load the MyTable : a XIB contain a tableView
let myTable = NSBundle.mainBundle().loadNibNamed("MyTable", owner: self, options: nil)[0] as! UITableView
// Set its frame and the background color.
myTable.frame = CGRectMake(CGFloat(i) * scrollView.frame.size.width, scrollView.frame.origin.y, scrollView.frame.size.width, scrollView.frame.size.height)
myTable.backgroundColor = sampleBGColors[i]
myTable.delegate = self
myTable.dataSource = self
self.currentTableView = myTable
let label = myTable.viewWithTag(1) as! UILabel
label.text = "Page #\(i + 1)"
scrollView.addSubview(myTable)
}
}
func configurePageControl() {
pageControl.numberOfPages = totalPages
pageControl.currentPage = 0
}
// MARK: UIScrollViewDelegate method implementation
func scrollViewDidScroll(scrollView: UIScrollView) {
// Calculate the new page index depending on the content offset.
let currentPage = floor(scrollView.contentOffset.x / UIScreen.mainScreen().bounds.size.width);
// Set the new page index to the page control.
pageControl.currentPage = Int(currentPage)
}
// MARK: IBAction method implementation
@IBAction func changePage(sender: AnyObject) {
// Calculate the frame that should scroll to based on the page control current page.
var newFrame = scrollView.frame
newFrame.origin.x = newFrame.size.width * CGFloat(pageControl.currentPage)
scrollView.scrollRectToVisible(newFrame, animated: true)
}
// Add here UITableViewDelegate and UITableViewDatasource methods..
}