How do I convert constraints's toItem or Item from viewA to viewB? I am getting this error: Unknown layout attributeHow to call Objective-C code from SwiftDownload data and display itSwift UIAlertController causing Autolayout Engine warningUITabBarItem action giving NSExceptionUIKit UIViewReportBrokenSuperviewChain exceptionCrashing app in XcodeNot able to Switch between View controllers ProgramaticallyUnrecognized selector sent to instance 0x7f995be07650Error in Swift Code?Getting UITableView error “unable to dequeue a cell with identifier cell”

Non-OR journals which regularly publish OR research

Are any jet engines used in combat aircraft water cooled?

What is my malfunctioning AI harvesting from humans?

Y2K... in 2019?

Why should we care about syntactic proofs if we can show semantically that statements are true?

Why are the inside diameters of some pipe larger than the stated size?

Why are Gatwick's runways too close together?

Why did Gandalf use a sword against the Balrog?

How do I explain to a team that the project they will work on for six months will certainly be cancelled?

Does the United States guarantee any unique freedoms?

What is the idiomatic way of saying “he is ticklish under armpits”?

Is refreshing multiple times a test case for web applications?

Does two puncture wounds mean venomous snake?

How many different ways are there to checkmate in the early game?

Was the 2019 Lion King film made through motion capture?

What are good ways to improve as a writer other than writing courses?

Plausibility of Ice Eaters in the Arctic

How do we avoid CI-driven development...?

Does a code snippet compile? Or does it get compiled?

sed delete all the words before a match

Acceptable to cut steak before searing?

In a topological space if there exists a loop that cannot be contracted to a point does there exist a simple loop that cannot be contracted also?

If a Contingency spell has been cast on a creature, does the Simulacrum spell transfer the contingent spell to its duplicate?

Can a one way NS Ticket be used as an OV-Chipkaart for P+R Parking in Amsterdam?



How do I convert constraints's toItem or Item from viewA to viewB? I am getting this error: Unknown layout attribute


How to call Objective-C code from SwiftDownload data and display itSwift UIAlertController causing Autolayout Engine warningUITabBarItem action giving NSExceptionUIKit UIViewReportBrokenSuperviewChain exceptionCrashing app in XcodeNot able to Switch between View controllers ProgramaticallyUnrecognized selector sent to instance 0x7f995be07650Error in Swift Code?Getting UITableView error “unable to dequeue a cell with identifier cell”






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















As title, I have the viewParent which has viewA,
but viewA will be replaced by viewB within method awakeAfter.



I wanna convert all of constraints




from viewParent <-> viewA,



to viewParent <-> viewB.




Thanks a lots.



Here is my code:



private func convertConstraints(from: UIView, to: UIView)
from.constraints.forEach (constraint: NSLayoutConstraint) in
let isFirst = (constraint.firstItem as? UIView) == from
let isSecond = (constraint.secondItem as? UIView) == from

let first: Any = (isFirst) ? to : constraint.firstItem as Any
let second: Any? = (isSecond) ? to : constraint.secondItem as? Any

let new = NSLayoutConstraint(item: first,
attribute: constraint.firstAttribute,
relatedBy: constraint.relation,
toItem: second,
attribute: constraint.secondAttribute,
multiplier: constraint.multiplier,
constant: constraint.constant)
new.priority = constraint.priority
new.identifier = constraint.identifier
new.shouldBeArchived = constraint.shouldBeArchived
new.isActive = constraint.isActive




And console log is below:



2019-03-27 15:36:33.740004+0800 Cale[86571:50392102] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'NSLayoutConstraint for <Cale.AirportButton: 0x7f9eb454d990; baseClass = UIButton; frame = (0 129; 120 120); autoresize = RM+BM; layer = <CALayer: 0x600003936460>>: Unknown layout attribute'
*** First throw call stack:
(
0 CoreFoundation 0x000000010bf501bb __exceptionPreprocess + 331
1 libobjc.A.dylib 0x000000010b4ee735 objc_exception_throw + 48
2 CoreFoundation 0x000000010bf50015 +[NSException raise:format:] + 197
3 Foundation 0x000000010a16cf61 ResolveConstraintArguments + 372
4 Foundation 0x000000010a16d2cb +[NSLayoutConstraint constraintWithItem:attribute:relatedBy:toItem:attribute:multiplier:constant:] + 80
.
.
.









share|improve this question


























  • Why don't you just remove the constraints and add them to the second view? make sure to add the constraints to the needed view after adding the view

    – Sanad Barjawi
    Mar 27 at 7:48











  • Instead of replacing the view. Create a container remove and add the required views from it.

    – Sachin Vas
    Mar 27 at 8:12











  • Because both of viewA which is initialized from code and viewB is loaded from Nib are the same class. And yes, I can remove the constraints but I also need add same them to the second view like the method doing.

    – Wei
    Mar 27 at 8:15











  • I'm based on following link and trying to refactor it. Creating custom UI components in iOS with Swift

    – Wei
    Mar 27 at 8:17


















0















As title, I have the viewParent which has viewA,
but viewA will be replaced by viewB within method awakeAfter.



I wanna convert all of constraints




from viewParent <-> viewA,



to viewParent <-> viewB.




Thanks a lots.



Here is my code:



private func convertConstraints(from: UIView, to: UIView)
from.constraints.forEach (constraint: NSLayoutConstraint) in
let isFirst = (constraint.firstItem as? UIView) == from
let isSecond = (constraint.secondItem as? UIView) == from

let first: Any = (isFirst) ? to : constraint.firstItem as Any
let second: Any? = (isSecond) ? to : constraint.secondItem as? Any

let new = NSLayoutConstraint(item: first,
attribute: constraint.firstAttribute,
relatedBy: constraint.relation,
toItem: second,
attribute: constraint.secondAttribute,
multiplier: constraint.multiplier,
constant: constraint.constant)
new.priority = constraint.priority
new.identifier = constraint.identifier
new.shouldBeArchived = constraint.shouldBeArchived
new.isActive = constraint.isActive




And console log is below:



2019-03-27 15:36:33.740004+0800 Cale[86571:50392102] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'NSLayoutConstraint for <Cale.AirportButton: 0x7f9eb454d990; baseClass = UIButton; frame = (0 129; 120 120); autoresize = RM+BM; layer = <CALayer: 0x600003936460>>: Unknown layout attribute'
*** First throw call stack:
(
0 CoreFoundation 0x000000010bf501bb __exceptionPreprocess + 331
1 libobjc.A.dylib 0x000000010b4ee735 objc_exception_throw + 48
2 CoreFoundation 0x000000010bf50015 +[NSException raise:format:] + 197
3 Foundation 0x000000010a16cf61 ResolveConstraintArguments + 372
4 Foundation 0x000000010a16d2cb +[NSLayoutConstraint constraintWithItem:attribute:relatedBy:toItem:attribute:multiplier:constant:] + 80
.
.
.









share|improve this question


























  • Why don't you just remove the constraints and add them to the second view? make sure to add the constraints to the needed view after adding the view

    – Sanad Barjawi
    Mar 27 at 7:48











  • Instead of replacing the view. Create a container remove and add the required views from it.

    – Sachin Vas
    Mar 27 at 8:12











  • Because both of viewA which is initialized from code and viewB is loaded from Nib are the same class. And yes, I can remove the constraints but I also need add same them to the second view like the method doing.

    – Wei
    Mar 27 at 8:15











  • I'm based on following link and trying to refactor it. Creating custom UI components in iOS with Swift

    – Wei
    Mar 27 at 8:17














0












0








0








As title, I have the viewParent which has viewA,
but viewA will be replaced by viewB within method awakeAfter.



I wanna convert all of constraints




from viewParent <-> viewA,



to viewParent <-> viewB.




Thanks a lots.



Here is my code:



private func convertConstraints(from: UIView, to: UIView)
from.constraints.forEach (constraint: NSLayoutConstraint) in
let isFirst = (constraint.firstItem as? UIView) == from
let isSecond = (constraint.secondItem as? UIView) == from

let first: Any = (isFirst) ? to : constraint.firstItem as Any
let second: Any? = (isSecond) ? to : constraint.secondItem as? Any

let new = NSLayoutConstraint(item: first,
attribute: constraint.firstAttribute,
relatedBy: constraint.relation,
toItem: second,
attribute: constraint.secondAttribute,
multiplier: constraint.multiplier,
constant: constraint.constant)
new.priority = constraint.priority
new.identifier = constraint.identifier
new.shouldBeArchived = constraint.shouldBeArchived
new.isActive = constraint.isActive




And console log is below:



2019-03-27 15:36:33.740004+0800 Cale[86571:50392102] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'NSLayoutConstraint for <Cale.AirportButton: 0x7f9eb454d990; baseClass = UIButton; frame = (0 129; 120 120); autoresize = RM+BM; layer = <CALayer: 0x600003936460>>: Unknown layout attribute'
*** First throw call stack:
(
0 CoreFoundation 0x000000010bf501bb __exceptionPreprocess + 331
1 libobjc.A.dylib 0x000000010b4ee735 objc_exception_throw + 48
2 CoreFoundation 0x000000010bf50015 +[NSException raise:format:] + 197
3 Foundation 0x000000010a16cf61 ResolveConstraintArguments + 372
4 Foundation 0x000000010a16d2cb +[NSLayoutConstraint constraintWithItem:attribute:relatedBy:toItem:attribute:multiplier:constant:] + 80
.
.
.









share|improve this question
















As title, I have the viewParent which has viewA,
but viewA will be replaced by viewB within method awakeAfter.



I wanna convert all of constraints




from viewParent <-> viewA,



to viewParent <-> viewB.




Thanks a lots.



Here is my code:



private func convertConstraints(from: UIView, to: UIView)
from.constraints.forEach (constraint: NSLayoutConstraint) in
let isFirst = (constraint.firstItem as? UIView) == from
let isSecond = (constraint.secondItem as? UIView) == from

let first: Any = (isFirst) ? to : constraint.firstItem as Any
let second: Any? = (isSecond) ? to : constraint.secondItem as? Any

let new = NSLayoutConstraint(item: first,
attribute: constraint.firstAttribute,
relatedBy: constraint.relation,
toItem: second,
attribute: constraint.secondAttribute,
multiplier: constraint.multiplier,
constant: constraint.constant)
new.priority = constraint.priority
new.identifier = constraint.identifier
new.shouldBeArchived = constraint.shouldBeArchived
new.isActive = constraint.isActive




And console log is below:



2019-03-27 15:36:33.740004+0800 Cale[86571:50392102] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'NSLayoutConstraint for <Cale.AirportButton: 0x7f9eb454d990; baseClass = UIButton; frame = (0 129; 120 120); autoresize = RM+BM; layer = <CALayer: 0x600003936460>>: Unknown layout attribute'
*** First throw call stack:
(
0 CoreFoundation 0x000000010bf501bb __exceptionPreprocess + 331
1 libobjc.A.dylib 0x000000010b4ee735 objc_exception_throw + 48
2 CoreFoundation 0x000000010bf50015 +[NSException raise:format:] + 197
3 Foundation 0x000000010a16cf61 ResolveConstraintArguments + 372
4 Foundation 0x000000010a16d2cb +[NSLayoutConstraint constraintWithItem:attribute:relatedBy:toItem:attribute:multiplier:constant:] + 80
.
.
.






swift






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 27 at 8:44









Chitra Khatri

9751 gold badge12 silver badges30 bronze badges




9751 gold badge12 silver badges30 bronze badges










asked Mar 27 at 7:45









WeiWei

417 bronze badges




417 bronze badges















  • Why don't you just remove the constraints and add them to the second view? make sure to add the constraints to the needed view after adding the view

    – Sanad Barjawi
    Mar 27 at 7:48











  • Instead of replacing the view. Create a container remove and add the required views from it.

    – Sachin Vas
    Mar 27 at 8:12











  • Because both of viewA which is initialized from code and viewB is loaded from Nib are the same class. And yes, I can remove the constraints but I also need add same them to the second view like the method doing.

    – Wei
    Mar 27 at 8:15











  • I'm based on following link and trying to refactor it. Creating custom UI components in iOS with Swift

    – Wei
    Mar 27 at 8:17


















  • Why don't you just remove the constraints and add them to the second view? make sure to add the constraints to the needed view after adding the view

    – Sanad Barjawi
    Mar 27 at 7:48











  • Instead of replacing the view. Create a container remove and add the required views from it.

    – Sachin Vas
    Mar 27 at 8:12











  • Because both of viewA which is initialized from code and viewB is loaded from Nib are the same class. And yes, I can remove the constraints but I also need add same them to the second view like the method doing.

    – Wei
    Mar 27 at 8:15











  • I'm based on following link and trying to refactor it. Creating custom UI components in iOS with Swift

    – Wei
    Mar 27 at 8:17

















Why don't you just remove the constraints and add them to the second view? make sure to add the constraints to the needed view after adding the view

– Sanad Barjawi
Mar 27 at 7:48





Why don't you just remove the constraints and add them to the second view? make sure to add the constraints to the needed view after adding the view

– Sanad Barjawi
Mar 27 at 7:48













Instead of replacing the view. Create a container remove and add the required views from it.

– Sachin Vas
Mar 27 at 8:12





Instead of replacing the view. Create a container remove and add the required views from it.

– Sachin Vas
Mar 27 at 8:12













Because both of viewA which is initialized from code and viewB is loaded from Nib are the same class. And yes, I can remove the constraints but I also need add same them to the second view like the method doing.

– Wei
Mar 27 at 8:15





Because both of viewA which is initialized from code and viewB is loaded from Nib are the same class. And yes, I can remove the constraints but I also need add same them to the second view like the method doing.

– Wei
Mar 27 at 8:15













I'm based on following link and trying to refactor it. Creating custom UI components in iOS with Swift

– Wei
Mar 27 at 8:17






I'm based on following link and trying to refactor it. Creating custom UI components in iOS with Swift

– Wei
Mar 27 at 8:17













1 Answer
1






active

oldest

votes


















1














I fixed it,... thanks a lot.



I modified code from:



let second: Any? = (isSecond) ? to : constraint.secondItem as? Any


to:



let second: Any? = (isSecond) ? to : constraint.secondItem





share|improve this answer

























  • type Optional<Any?> v.s. Any?

    – Wei
    Mar 27 at 8:51










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55372094%2fhow-do-i-convert-constraintss-toitem-or-item-from-viewa-to-viewb-i-am-getting%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














I fixed it,... thanks a lot.



I modified code from:



let second: Any? = (isSecond) ? to : constraint.secondItem as? Any


to:



let second: Any? = (isSecond) ? to : constraint.secondItem





share|improve this answer

























  • type Optional<Any?> v.s. Any?

    – Wei
    Mar 27 at 8:51















1














I fixed it,... thanks a lot.



I modified code from:



let second: Any? = (isSecond) ? to : constraint.secondItem as? Any


to:



let second: Any? = (isSecond) ? to : constraint.secondItem





share|improve this answer

























  • type Optional<Any?> v.s. Any?

    – Wei
    Mar 27 at 8:51













1












1








1







I fixed it,... thanks a lot.



I modified code from:



let second: Any? = (isSecond) ? to : constraint.secondItem as? Any


to:



let second: Any? = (isSecond) ? to : constraint.secondItem





share|improve this answer













I fixed it,... thanks a lot.



I modified code from:



let second: Any? = (isSecond) ? to : constraint.secondItem as? Any


to:



let second: Any? = (isSecond) ? to : constraint.secondItem






share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 27 at 8:50









WeiWei

417 bronze badges




417 bronze badges















  • type Optional<Any?> v.s. Any?

    – Wei
    Mar 27 at 8:51

















  • type Optional<Any?> v.s. Any?

    – Wei
    Mar 27 at 8:51
















type Optional<Any?> v.s. Any?

– Wei
Mar 27 at 8:51





type Optional<Any?> v.s. Any?

– Wei
Mar 27 at 8:51






Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55372094%2fhow-do-i-convert-constraintss-toitem-or-item-from-viewa-to-viewb-i-am-getting%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현