天道酬勤,学无止境

constraints

iOS Auto Layout Constraint's Jumping After View Has Loaded

Question Made a quick video demonstrating the issue here: https://vid.me/9kB5 When I remove the constraints the text does not jump upon loading the view. But then it defeats the purpose. When I setup the constraints I used "Reset to Suggested Constraints" Any ideas? Answer1 This is not a constraint issue. Your view is going under the navigation bar. You can fix it in storyboard by unchecking "Extend Edges - Under Top Bar" in Page View Controller scene. In code - (void)viewDidLoad { [super viewDidLoad]; self.edgesForExtendedLayout = UIRectEdgeNone; } Answer2 Hari Kunwar's answer didn't work for

2021-09-23 16:34:08    分类:技术分享    ios   autolayout   constraints

Using Page View Controller inside Tab Swift

Question MY WORK SO FAR: So I have a Tab bar that looks like this: When I click on "Canteen" I want to be directed to a Page View Controller where I can swipe between different pages but stay on the same tab. I have this somewhat working: I have the Storyboard setup like this: As you can see that segue above is coming from the Tab Bar Controller. The third view (Can Page Item Controller, ID: "CanItemController) is used for all pages in the page view. The second view above (Page View Controller, ID: "CanPageController) is used for controlling the Pages (duh) The first view

2021-09-23 15:59:50    分类:技术分享    ios   swift   uitabbarcontroller   constraints   uipageviewcontroller

Not null attribute in Neo4J constraint

Question It is possible to create constraint in Neo4J database for attribute to be not null? Something like: CREATE CONSTRAINT ON (p:Person) ASSERT p.name IS NOT NULL Answer1 It's planned and been already implemented for Neo4j 2.3, should be available with 2.3.RC1

2021-09-22 08:10:15    分类:技术分享    neo4j   constraints   cypher

Minimization with R nloptr package - multiple equality constraints

Question Is it possible to specify more than one equality constraint in nloptr function in R? The code that I am trying to run is the following: eval_f <- function( x ) { return( list( "objective" = x[3]^2+x[4]^2, "gradient" = c( 0, 0, 2*x[3], 2*x[4] ) ) ) } # constraint functions # equalities eval_g_eq <- function( x ) { constr <- c( x[1] + x[2] + x[3] - 4, x[1]^2 + x[2]^2 + x[4] - 15 ) grad <- c( c(1, 1, 1, 0), c(2*x[1], 2*x[2], 0, 1) ) return( list( "constraints"=constr, "jacobian"=grad ) ) } # initial values x0 <- c( 1, 5, 5, 1 ) local_opts <- list( "algorithm" = "NLOPT_LD_MMA", "xtol_rel"

2021-09-22 07:52:18    分类:技术分享    r   constraints   equality   nonlinear-optimization   nlopt

add constraints programmatically swift

Question I am trying to add constraints to a facebook sdk login button. I have the button inside a scroll view and I am trying to add a top constraint to a label that is also in the scroll view. I am able to successfully add the height constraint with no run time errors but the actual constraint does not seem to be applied to the button. @IBOutlet weak var orLbl: UILabel! @IBOutlet weak var scrollView: UIScrollView! override func viewDidLoad() { super.viewDidLoad() var loginFBButton = FBSDKLoginButton() loginFBButton.readPermissions = ["public_profile", "email"] let heightConstraint =

2021-09-22 02:09:52    分类:技术分享    ios   swift   constraints   nslayoutconstraint

Adding programatically created views into scrollview vertically (Linear layout in iOS)

Question I want to add programatically created UIViews into scrollView with auto layout constraints. Like vertical linear layout in Android. (In objective c not swift) I have scrollview inside view controller in storyboard. So basically i want to create and add several views in vertical layout with no spaces into that scrollview. And i want to set container size of the scroll view dynamically according to the view heights. Each view has label inside and each view needs to set its height dynamically according to text size. But probably i need to come to that later. for (int i=0; i<10; i++) {

2021-09-21 23:05:27    分类:技术分享    ios   objective-c   autolayout   constraints

PostgreSQL unique value acreoss multiple columns

Question I have PostgreSQL table id ColA ColB ------------------ 1 'a' 'b' 2 'c' 'd' I want to make values in ColA and ColB to be unique across both columns i.e. any of these inserts would be forbidden: INSERT INTO table (ColA,ColB) values('a','e'); INSERT INTO table (ColA,ColB) values('z','a'); INSERT INTO table (ColA,ColB) values('d','g'); and any of these inserts would be allowed: INSERT INTO table (ColA,ColB) values('z','e'); INSERT INTO table (ColA,ColB) values('l','k'); So CONSTRAINT unique_name UNIQUE (ColA,ColB) is not suited, because it will allow any of previous 4 inserts. Answer1

2021-09-21 12:28:10    分类:技术分享    postgresql   constraints   unique

How can I change the aspect ratio constraint value from code?

Question I have given an aspect ratio constraint of 1:2 for an imageView in my xib. I have created an IBOutlet for the constraint. Now I need to change the aspect ratio to 1:1 for certain criteria. I want to know whether there is any way to change the constraint's multiplier value other than removing the old constraint and putting in a new one?? Answer1 I think its not possible other than the 'remove and replace constraint' method. Answer2 The multiplier is a get only property. So you can change only constant and isActive. The constant for this constraint changes the height. If constant ==

2021-09-21 12:25:27    分类:技术分享    ios   constraints   aspect-ratio

How to get CAShapeLayer to work with constraints with swift?

Question i got this in viewdidload rectShape1 = CAShapeLayer() rectShape1.fillColor = UIColor.blueColor().CGColor rectShape1.path = UIBezierPath(roundedRect: rectShape1.bounds, byRoundingCorners: .BottomLeft | .TopRight, cornerRadii: CGSize(width: 20, height: 20)).CGPath redview.layer.addSublayer(rectShape1) var constTop = NSLayoutConstraint(item: redview, attribute: NSLayoutAttribute.CenterX, relatedBy: NSLayoutRelation.Equal, toItem: view, attribute: NSLayoutAttribute.CenterX, multiplier: 1, constant: 0) view.addConstraint(constTop) var constH = NSLayoutConstraint(item: redview, attribute

2021-09-21 06:51:04    分类:技术分享    ios   swift   constraints   cashapelayer

How to get CAShapeLayer to work with constraints with swift?

Question i got this in viewdidload rectShape1 = CAShapeLayer() rectShape1.fillColor = UIColor.blueColor().CGColor rectShape1.path = UIBezierPath(roundedRect: rectShape1.bounds, byRoundingCorners: .BottomLeft | .TopRight, cornerRadii: CGSize(width: 20, height: 20)).CGPath redview.layer.addSublayer(rectShape1) var constTop = NSLayoutConstraint(item: redview, attribute: NSLayoutAttribute.CenterX, relatedBy: NSLayoutRelation.Equal, toItem: view, attribute: NSLayoutAttribute.CenterX, multiplier: 1, constant: 0) view.addConstraint(constTop) var constH = NSLayoutConstraint(item: redview, attribute

2021-09-21 06:49:05    分类:技术分享    ios   swift   constraints   cashapelayer