EXC_BAD_INSTRUCTION error

耗尽温柔 提交于 2019-12-02 18:17:06

问题


I know that there are a lot of questions about this error, but I haven't found solution for my problem, even if I read most of them. In view controller I'm trying to make my text view displaying top of text, instead of bottom of it. When there is only one textView, then everything works perfectly, but when I try do it with two of the, , then I get EXC_BAD_INSTRUCTION error.

import UIKit
import Social

class ViewController: UIViewController {

@IBOutlet weak var textViewA: UITextView!
@IBOutlet weak var textViewB: UITextView!

override func viewDidLoad() {
    super.viewDidLoad()

}

override func viewDidLayoutSubviews() {
    super.viewDidLayoutSubviews()

    textViewA.setContentOffset(CGPointZero, animated: false)
    textViewB.setContentOffset(CGPointZero, animated: false)

}

回答1:


If your error is like this

Then it is because you have not hooked up your outlets, to do this go into the storyboard / nib and hook it up like so:

Make sure they are valid by seeing the circles become solid:




回答2:


This code works for me. I tested it on my own. This is mostly an outlet error, if they aren't connected correctly. It could also be that you have removed an outlet from your code and still have it connected inside your storyboard.



来源:https://stackoverflow.com/questions/35102749/exc-bad-instruction-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!