简体   繁体   中英

EXC_BAD_INSTRUCTION error

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)

}

If your error is like this

EXEC_BAD_INSTRUCTION

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:

固体

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM