当我按下它时UIViewController,它在新的后退按钮中有一些标题UIViewController,如果标题有很多文本,它在iPhone 4s看起来不太好所以我想删除它.
如果我在prepareForSegue函数中添加一些代码,那将是一个麻烦.
有没有更好的方法实现这一目标
我想实现一个功能,当我单击按钮时,图像将在两个按钮之间移动
我在图像和button2之间设置了一个约束(centerX,带有222的文本)同时我也用button1设置约束(centerX,带有11的文本)并用950设置优先级然后我将它们拖到 viewcontroller
这是我的故事板中的约束

这是我控制约束的代码
if NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_7_1 {
self.kidLeftCenterConstrait.active = isLeft
self.kidRightCenterConstrait.active = !isLeft
UIView.animateWithDuration(kAnimationDuration, animations: { () -> Void in
self.view.layoutIfNeeded()
})
} else {
let constraintToRemove = isLeft ? self.kidRightCenterConstrait : self.kidLeftCenterConstrait
let constriaintToUse = isLeft ? self.kidLeftCenterConstrait : self.kidRightCenterConstrait
self.douBi.superview!.removeConstraint(constraintToRemove)
self.douBi.superview!.removeConstraint(constriaintToUse)
self.douBi.superview!.addConstraint(constriaintToUse)
UIView.animateWithDuration(kAnimationDuration, animations: { () -> Void in
self.view.layoutIfNeeded()
})
}
Run Code Online (Sandbox Code Playgroud)
在iphone中运行后,我点击按钮1,图像移动到11,然后我点击按钮2,应用程序是现金 self.kidRightCenterConstrait.active = !isLeft
控制台日志是 fatal error:unexpectedly found nil while unwrapping an Optional value