gpt4 book ai didi

ios - 使用textview滚动方法时的EXC_BAD_ACCESS AppDelegate

转载 作者:行者123 更新时间:2023-11-29 01:48:51 25 4
gpt4 key购买 nike

我有一个弹出窗口,当我滚动 TextView 并关闭弹出窗口时,我在应用程序委托(delegate)中获得 EXC_BAD_ACCESS。

下面的代码用于 TextView 滚动

func textViewDidBeginEditing(textView: UITextView) {
var scrollPoint : CGPoint = CGPointMake(0.0, textView.frame.origin.y + 300)
isFormInputChanged = true
self.contentScrollView.setContentOffset(scrollPoint, animated: true)
}

func textViewDidEndEditing(textView: UITextView) {
self.contentScrollView.setContentOffset(CGPointZero, animated: true)
}

关闭弹窗的代码

    if isFormInputChanged == true
{
var pagetitle = dict[constants.lable.WARNING_TITLE]
var button1Title = dict[constants.lable.YES]
var button2Title = dict[constants.lable.NO]
var alertMessage = dict[constants.lable.alert.CANCEL_UNIT_SAVE_ALERT]
customControllerWithCancelForm(pagetitle!, button1Title: button1Title!, button2Title: button2Title!, alertMessage: alertMessage!)
}
else
{
var tmpController :UIViewController! = self.presentingViewController
self.dismissViewControllerAnimated(false, completion: {()->Void in
self.unitDetailProtocolVar!.closeUnitDetail()
});
}

有人可以告诉我我做错了什么吗?

谢谢,

最佳答案

您进行了过多的强制展开。您应该始终执行可选绑定(bind):

  if isFormInputChanged == true 
{
if let pagetitle = dict[constants.lable.WARNING_TITLE],
button1Title = dict[constants.lable.YES],
button2Title = dict[constants.lable.NO],
alertMessage = dict[constants.lable.alert.CANCEL_UNIT_SAVE_ALERT]
{
customControllerWithCancelForm(pagetitle, button1Title: button1Title, button2Title: button2Title, alertMessage: alertMessage)
}
}
else
{
self.dismissViewControllerAnimated(false, completion: { () -> Void in
if let unitDetailProtocolVar = self.unitDetailProtocolVar {
unitDetailProtocolVar.closeUnitDetail()
}
});
}

关于ios - 使用textview滚动方法时的EXC_BAD_ACCESS AppDelegate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31635919/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com