EXC_BAD_INSTRUCTION 错误 [英] EXC_BAD_INSTRUCTION error

查看:83
本文介绍了EXC_BAD_INSTRUCTION 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道有很多关于这个错误的问题,但我还没有找到解决我的问题的方法,即使我阅读了其中的大部分.在视图控制器中,我试图让我的文本视图显示文本的顶部,而不是底部.当只有一个 textView 时,一切正常,但是当我尝试使用其中的两个, 时,我会收到 EXC_BAD_INSTRUCTION 错误.

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)

}

推荐答案

如果你的错误是这样的

那是因为你还没有连接你的插座,要做到这一点,请进入故事板/笔尖并像这样连接:

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:

这篇关于EXC_BAD_INSTRUCTION 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆