Auto Layout
  [ Ignoră ]
Avatar
RankRankRankRank
Sr. Member
Din: Bucuresti
Macuser din: 22.09.06

Folositi? Pare util dar pana acum am fost nevoit ii dau “disable” pentru ca nu se intelege bine cu scrollView/tableView/collectionView, in general cu orice view ce are contentSize.
O alta problema am intampinat cand am folosit translatie pe axa z pentru perspectiva, Auto Layout in loc sa centreze view-urile, mi le punea in partea stanga.
Inca nu am inteles in ce masura pot folosi setFrame cu AutoLayout ON. Inteleg ca translatesAutoresizingMaskIntoConstraints este ON ca default si ce adaug un biew in cod, autoresizing mask-ul este transformat in constraint la runtime, dar, daca view-ul adaugat in cod este al unui child Vc creat din storyboard, cine e responsabil pt layout? In storyboard daca Auto Layout e ON are deja constraint-urile puse acolo…
Daca a folosit cineva mai mult Auto Layout astept ceva pareri smile

 Semnătură 

A man should look for what is, and not for what he thinks should be.—Albert Einstein

Profil
 
  [ Ignoră ]   [ # 1 ]
Avatar
RankRankRankRank
Moderator
Din: Cluj-Napoca
Macuser din: 26.01.06

Folosesc dar numai din cod cu autoresizingMask (eu nu folosesc nib-uri deloc de fapt). Am intampinat o singura problema pana acum, poate ai observat-o si tu la aplicatia care ti-am dat-o pt test. Am 4 cercuri asezate uniform pe latimea ecranului, toate au autoresizing pt marginile din stanga si dreapta dar cand se intoarce pe landscape doar primul cerc se aseaza unde trebuie, restul se duc in dreapta putin cate putin.
Setarile unui nib cred ca sunt suprascrise de cele din cod, deci daca nu-i faci nimic ar trebui sa fie valabile alea din storyboard.

 Semnătură 

Mcintoshing…

Profil
 
  [ Ignoră ]   [ # 2 ]
Avatar
RankRankRankRank
Sr. Member
Din: Bucuresti
Macuser din: 22.09.06

Pai in general la mine primul controller il folosesc ca si container, restul controllerelor din storyboard, create cu instantiateViewControllerWithIdentifier le adaug ca childControllere, eventual cu animatii custom.
Daca in container folosesc traditionalul setFrame: e ok, cu AutoLayout am avut n probleme.
In general daca le las asa am inteles ca e ok, autoresizing mask-urile pa runtime se transforma in constrains, dar pot aparea surprize din ce am inteles…
Am trimis si 2 proiecte la Apple, am pus p intrebare inginerilor poate ma lamuresc ei smile

 Semnătură 

A man should look for what is, and not for what he thinks should be.—Albert Einstein

Profil
 
  [ Ignoră ]   [ # 3 ]
Avatar
RankRankRankRank
Moderator
Din: Cluj-Napoca
Macuser din: 26.01.06

App, este in itunes o lectie despre autolayout pe 31 ian 2013, ai vazut? M-am uitat putin si e buna, ca toate a lui Paul Hegarty dealtfel.

 Semnătură 

Mcintoshing…

Profil
 
  [ Ignoră ]   [ # 4 ]
Avatar
RankRankRankRank
Sr. Member
Din: Bucuresti
Macuser din: 22.09.06

Alea le-am vazut dar sunt chestii basic, am cumparat cartea asta: http://www.amazon.com/Layout-Demystified-Mobile-Programming-ebook/dp/B00C68XS0S

 Semnătură 

A man should look for what is, and not for what he thinks should be.—Albert Einstein

Profil
 
  [ Ignoră ]   [ # 5 ]
Avatar
RankRankRankRank
Sr. Member
Din: Bucuresti
Macuser din: 22.09.06

Vad ca la scrollView a clarificat Apple lucrurile smile
http://developer.apple.com/library/ios/ipad/#technotes/tn2154/_index.html

 Semnătură 

A man should look for what is, and not for what he thinks should be.—Albert Einstein

Profil
 
  [ Ignoră ]   [ # 6 ]
Avatar
RankRankRankRank
Moderator
Din: Cluj-Napoca
Macuser din: 26.01.06

M-am mutat si eu recent pe autolayout pt ca sunt locuri in care nu mai merg mastile, e cam mult de scris din cod cum fac eu dar asta e, poate fac clase speciale doar pt layout ca sa nu poluez.
Am o intrebare pt tine poate stii, vreau sa modific doar inaltimea dar vrea regula si pt latime ca sa functioneze, altfel imi face latimea 0. E normal?

constraint [NSLayoutConstraint constraintWithItem:scrollView
                                                  attribute
:NSLayoutAttributeHeight
                                                  relatedBy
:NSLayoutRelationEqual
                                                     toItem
:self
                                                  attribute
:NSLayoutAttributeHeight
                                                 multiplier
:1.0f
                                                   constant
:-50.f];
        
[self addConstraint:constraint]
 Semnătură 

Mcintoshing…

Profil
 
  [ Ignoră ]   [ # 7 ]
Avatar
RankRankRankRank
Moderator
Din: Cluj-Napoca
Macuser din: 26.01.06

Acum am observat ca primesc si un warning in consola

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. (Note: If you’re seeing NSAutoresizingMaskLayoutConstraints that you don’t understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(   “<NSLayoutConstraint:0x1fd525b0 UIScrollView:0x1fde4310.height == XYZView:0x1fd9f0f0.height - 50>”,
  “>”,
  “>”
)

Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x1fd525b0 UIScrollView:0x1fde4310.height == ReminderDetailedView:0x1fd9f0f0.height - 50>


Break on objc_exception_throw to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.

 Semnătură 

Mcintoshing…

Profil
 
  [ Ignoră ]   [ # 8 ]
Avatar
RankRankRankRank
Sr. Member
Din: Bucuresti
Macuser din: 22.09.06

Cand pui in cod constrain-uri pentru view-ul respectiv dupa ce il creezi primul lucru trebuie sa setezi apelezi: setTranslatesAutoresizingMaskIntoConstraints: NO, altfel si autoresizing mask-urile sunt transformate in constrain-uri.

 Semnătură 

A man should look for what is, and not for what he thinks should be.—Albert Einstein

Profil
 
  [ Ignoră ]   [ # 9 ]
Avatar
RankRankRankRank
Sr. Member
Din: Bucuresti
Macuser din: 22.09.06

Daca poti sa pui view-ul din IB cel mai bune unde vrei height dinamic creezi outlet pentru constrain-ul respectiv si modifici proprietatea “constant” cum ai nevoie.

 Semnătură 

A man should look for what is, and not for what he thinks should be.—Albert Einstein

Profil