我在去一个新的
ViewController
新的
有
scrollView
origin y: 0
.
这个
有一个
textView
原点y:0
.
模拟器
,它向我展示了
出于某种原因,在屏幕中间的某个地方。
这是我的代码:
class addViewController: UIViewController, UIPickerViewDelegate, UIScrollViewDelegate {
var textView = UITextView()
var scrollView = UIScrollView()
  override func viewDidLoad() {
super.viewDidLoad()
scrollView.frame = CGRect(x: 0, y: 0, width: view.frame.width, height: view.frame.height)
view.addSubview(scrollView)
textView.frame = CGRect(x: 20.0, y: 0, width: 250.0, height: 100.0)
textView.center = self.view.center
textView.textAlignment = NSTextAlignment.justified
textView.textColor = UIColor.blue
textView.backgroundColor = UIColor.lightGray
textView.text = "texttttt"
scrollView.addSubview(textView)
scrollView.contentSize = CGSize(width: view.frame.width, height: view.frame.height)
}
要做到这一点
视图控制器
视图控制器
,这是
didSelectCellAt
:
let addNoteVC = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "addViewController") as! addViewController
self.navigationController?.pushViewController(addNoteVC, animated: true)