I make a Today Notification Widget
and I use AutoLayout
.
When I press a number button, whole view moves to left. I cannot figure out why.
Why view moves left when I tap a button? Is it from AutoLayout
or is a general problem?
This appears to be a problem with your implementation. There's no reason for this to happen unless you are changing some positions or autolayout constraints when tapping a button. also, you may want to take a look at widgetMarginInsetsForProposedMarginInsets
function and that you are already inheriting from NCWidgetProviding
:
class MainViewController: UIViewController, NCWidgetProviding {
func widgetMarginInsetsForProposedMarginInsets(defaultMarginInsets: UIEdgeInsets) -> UIEdgeInsets {
return UIEdgeInsetsZero
}
}
...anyway, your question is really broad the way it's stated here, maybe you will want to add some source for further insight.
Hope it helps!
UPDATE:
The problem is that when you input some text, the margins of that view get's bigger, and that's doing something weird because there is some constraint that you are missing and that is related to the view (your UITextField
/UILabel
) that is giving value to your right side leading margin constraint.
If you isolate completely, right part from Left, maybe putting both of them in separated views. You should be able to resolve this issue as any changes inside of the left view, remains in the left view.
Other way is to remove all constrains and start over, putting your constrains manually, do not let xcode do that job for you