How to disable automatic layout for presentation from code?

I did not use automatic layout because I need to support iOS 5. Now I get an NSInternalInconsistencyException when the controller is clicked:

Terminating app due to uncaught exception 'NSInternalInconsistencyException',
reason: 'Auto Layout still required after executing -layoutSubviews.
SGBExampleView implementation of -layoutSubviews needs to call super.'

My implementation of layoutSubviews calls [super layoutSubviews], so it is useless. Something seems to have included Auto Layout for my presentation; I would like to disable it again. However, all I can find that says how to disable it, says to do it from IB. I do not use IB. How to disable automatic layout for presentation from code?

UPDATE:

This question is not a duplicate, since the other relates specifically to the UITableViewCell subclass, and setting translatesAutoresizingMaskIntoConstraintseither YES or NO has no effect.

+3
source share
2 answers

To disable auto-layout for a view, just do not create restrictions associated with this view:

To provide additional compatibility, all restrictions based on the restrictions of the layout system are generally inactive until you set a restriction on the view.

See Cocoa Auto Layout Guide . Yes, this applies to Cocoa, not iOS. However, the principle will be the same.

+1
source

, , . , , ( ):

1) , .

2) , alloc/init .

3) .

, !

. :

[ removeConstraints: view.constraints] .

0

All Articles