2015-03-13 1 views
1

Я использую панель рассказов для создания ui для своего приложения и использует swift & Я подготовил ниже макет, который вы можете увидеть на снимке экрана. enter image description hereКак переместить представление с помощью быстрого в iOS?

Я хочу скрыть информацию, содержащую сведения о stop1 & place stop2 view вместо stop1 во время выполнения.

Я использую следующий код, чтобы скрыть Окончание1 & обновления ограничение STOP2

stop1Frame.hidden = true 
    stop2Frame.updateConstraints() 

Пожалуйста, помогите мне.

установка ограничения длины на 0 из stop1 работала, но показывает ниже ошибки в консоли.

2015-03-13 17:03:52.738 GroundSpan[5392:1777378] Unable to simultaneously satisfy constraints. 
    Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 
    (
    "<NSLayoutConstraint:0x7a644500 V:[UILabel:0x7a643d50'Please tap on + button to...'(63)]>", 
    "<NSLayoutConstraint:0x7a64cb80 V:[UIView:0x7a63aaa0(0)]>", 
    "<NSLayoutConstraint:0x7a64cc10 UILabel:0x7a632e20'Stop1'.top == UIView:0x7a63aaa0.topMargin>", 
    "<NSLayoutConstraint:0x7a64d2b0 V:[UILabel:0x7a643d50'Please tap on + button to...']-(20)-| (Names: '|':UIView:0x7a63aaa0)>", 
    "<NSLayoutConstraint:0x7a64d310 V:[UILabel:0x7a632e20'Stop1']-(NSSpace(8))-[UILabel:0x7a643d50'Please tap on + button to...']>") 

Will attempt to recover by breaking constraint 

<NSLayoutConstraint:0x7a644500 V:[UILabel:0x7a643d50'Please tap on + button to...'(63)]> 

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger. 
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful. 
2015-03-13 17:03:52.739 GroundSpan[5392:1777378] Unable to simultaneously satisfy constraints. 
    Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 
(
    "<NSLayoutConstraint:0x7a64cb80 V:[UIView:0x7a63aaa0(0)]>", 
    "<NSLayoutConstraint:0x7a64cc10 UILabel:0x7a632e20'Stop1'.top == UIView:0x7a63aaa0.topMargin>", 
    "<NSLayoutConstraint:0x7a64d2b0 V:[UILabel:0x7a643d50'Please tap on + button to...']-(20)-| (Names: '|':UIView:0x7a63aaa0)>", 
    "<NSLayoutConstraint:0x7a64d310 V:[UILabel:0x7a632e20'Stop1']-(NSSpace(8))-[UILabel:0x7a643d50'Please tap on + button to...']>" 
) 

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x7a64d310 V:[UILabel:0x7a632e20'Stop1']-(NSSpace(8))-[UILabel:0x7a643d50'Please tap on + button to...']> 

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger. 
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful. 
+0

Где ваш код Swift? – Raptor

+0

быстрый код добавил, что я использую, чтобы скрыть и обновить ограничение – Pinakin

ответ

2

Создание IBOutlet на ограничение высоты Окончание1, так что вы можете получить доступ к нему в вашем коде.

Чтобы скрыть stop1, установите ограничение по высоте на 0, поэтому stop2 будет двигаться вверх.

@IBOutlet weak var stop1HeightConstraint: NSLayoutConstraint! 
... 

// in your function: 
self.stop1HeightConstraint.constant = 0 

UIView.animateWithDuration(0.4, animations: { 
    self.view.layoutIfNeeded() 
}) 

Все это предполагает, что вы правильно настроили автоопределение и ограничения.

+0

Ваш трюк заставит stop2 переместиться вместо stop1, но дает ошибку в консоли, пожалуйста, посмотрите отредактированный вопрос для журнала ошибок. – Pinakin

+0

Вот что я имел в виду в последнем предложении моего ответа: ваши ограничения необходимо правильно настроить. Мы не можем видеть, как вы устанавливаете ограничения. Белыми ячейками должны быть UIViews, а метки и кнопки в них должны располагаться относительно этого родительского представления. – zisoft

+0

Я не видел ни одной красной или желтой линии. Все прекрасно сочетается с синим, что означает, что все ограничения настроены довольно хорошо. Но все еще получаю это сообщение. – Pinakin

Смежные вопросы