Использование свойства ширины UIScreen нарушает ограничение UITableViewCell - PullRequest
1 голос
/ 25 февраля 2020

Я пытаюсь ограничить UITableViewCell программно. Моя клетка состоит из простого пейджера. Мой init метод ячейки включает следующее.

height =  UIScreen.main.bounds.width * 0.56 // If I use static i.e 320 value it is ok. 
width = UIScreen.main.bounds.width is ok.
pagerView.topAnchor.constrain(to: topAnchor)
pagerView.bottomAnchor.constrain(to: bottomAnchor)
pagerView.widthAnchor.constrain(to: width)
pagerView.heightAnchor.constrain(to: height)

Когда я пытаюсь ограничить использование UIScreen.main.bounds.width, это выдает мне следующую ошибку. Однако, если я использую значение stati c 320 вместо UIScreen width, это все хорошо.

> 2020-02-25 16:07:44.209043+0300 myApp[23049:780168]
> [LayoutConstraints] 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.  (
>     "<NSLayoutConstraint:0x6000035345f0 V:|-(0)-[FSPagerView.FSPagerView:0x7fb96c6226f0]   (active, names:
> '|':myApp.HomePagerCell:0x7fb96e041c00'HomePagerCell' )>",
>     "<NSLayoutConstraint:0x6000035346e0 FSPagerView.FSPagerView:0x7fb96c6226f0.bottom ==
> myApp.HomePagerCell:0x7fb96e041c00'HomePagerCell'.bottom   (active)>",
>     "<NSLayoutConstraint:0x600003534780 FSPagerView.FSPagerView:0x7fb96c6226f0.height == 231.84   (active)>",
>     "<NSLayoutConstraint:0x600003534aa0 'UIView-Encapsulated-Layout-Height'
> myApp.HomePagerCell:0x7fb96e041c00'HomePagerCell'.height == 232  
> (active)>" ) Will attempt to recover by breaking constraint 
> <NSLayoutConstraint:0x600003534780
> FSPagerView.FSPagerView:0x7fb96c6226f0.height == 231.84   (active)>
> Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints
> to catch this in the debugger. The methods in the
> UIConstraintBasedLayoutDebugging category on UIView listed in
> <UIKitCore/UIView.h> may also be helpful.

В чем может быть причина этого и как я могу его решить?

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...