Permalink
Browse files

second commit

  • Loading branch information...
Alex311 committed Nov 18, 2013
1 parent 02f2827 commit bde387b27e33605eeac3465475d2f2ff9775f163
Showing with 1,690 additions and 0 deletions.
  1. BIN .DS_Store
  2. +485 −0 TableViewCellWithAutoLayout.xcodeproj/project.pbxproj
  3. +7 −0 TableViewCellWithAutoLayout.xcodeproj/project.xcworkspace/contents.xcworkspacedata
  4. BIN ....xcodeproj/project.xcworkspace/xcuserdata/alexhutchins.xcuserdatad/UserInterfaceState.xcuserstate
  5. +23 −0 ...WithAutoLayout.xcodeproj/xcuserdata/alexhutchins.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
  6. +96 −0 ...yout.xcodeproj/xcuserdata/alexhutchins.xcuserdatad/xcschemes/TableViewCellWithAutoLayout.xcscheme
  7. +27 −0 ...llWithAutoLayout.xcodeproj/xcuserdata/alexhutchins.xcuserdatad/xcschemes/xcschememanagement.plist
  8. +96 −0 ...toLayout.xcodeproj/xcuserdata/kmuldoon.xcuserdatad/xcschemes/TableViewCellWithAutoLayout.xcscheme
  9. +27 −0 ...ewCellWithAutoLayout.xcodeproj/xcuserdata/kmuldoon.xcuserdatad/xcschemes/xcschememanagement.plist
  10. BIN TableViewCellWithAutoLayout/.DS_Store
  11. +53 −0 TableViewCellWithAutoLayout/Images.xcassets/AppIcon.appiconset/Contents.json
  12. +51 −0 TableViewCellWithAutoLayout/Images.xcassets/LaunchImage.launchimage/Contents.json
  13. +34 −0 TableViewCellWithAutoLayout/RJAppDelegate.h
  14. +70 −0 TableViewCellWithAutoLayout/RJAppDelegate.m
  15. +45 −0 TableViewCellWithAutoLayout/TableViewCellWithAutoLayout-Info.plist
  16. +16 −0 TableViewCellWithAutoLayout/TableViewCellWithAutoLayout-Prefix.pch
  17. +35 −0 TableViewCellWithAutoLayout/TableViewController/RJModel.h
  18. +77 −0 TableViewCellWithAutoLayout/TableViewController/RJModel.m
  19. +39 −0 TableViewCellWithAutoLayout/TableViewController/RJTableViewCell.h
  20. +200 −0 TableViewCellWithAutoLayout/TableViewController/RJTableViewCell.m
  21. +31 −0 TableViewCellWithAutoLayout/TableViewController/RJTableViewController.h
  22. +200 −0 TableViewCellWithAutoLayout/TableViewController/RJTableViewController.m
  23. +2 −0 TableViewCellWithAutoLayout/en.lproj/InfoPlist.strings
  24. +18 −0 TableViewCellWithAutoLayout/main.m
  25. BIN TableViewCellWithAutoLayoutTests/.DS_Store
  26. +22 −0 TableViewCellWithAutoLayoutTests/TableViewCellWithAutoLayoutTests-Info.plist
  27. +34 −0 TableViewCellWithAutoLayoutTests/TableViewCellWithAutoLayoutTests.m
  28. +2 −0 TableViewCellWithAutoLayoutTests/en.lproj/InfoPlist.strings
BIN +6 KB .DS_Store
Binary file not shown.

Large diffs are not rendered by default.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "1"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "TableViewCellWithAutoLayout/TableViewController/RJTableViewCell.m"
timestampString = "406490894.690064"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "168"
endingLineNumber = "168"
landmarkName = "-updateConstraints"
landmarkType = "5">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
@@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0500"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "99BCDCA018008C0000B8E66B"
BuildableName = "TableViewCellWithAutoLayout.app"
BlueprintName = "TableViewCellWithAutoLayout"
ReferencedContainer = "container:TableViewCellWithAutoLayout.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "99BCDCBB18008C0000B8E66B"
BuildableName = "TableViewCellWithAutoLayoutTests.xctest"
BlueprintName = "TableViewCellWithAutoLayoutTests"
ReferencedContainer = "container:TableViewCellWithAutoLayout.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "99BCDCA018008C0000B8E66B"
BuildableName = "TableViewCellWithAutoLayout.app"
BlueprintName = "TableViewCellWithAutoLayout"
ReferencedContainer = "container:TableViewCellWithAutoLayout.xcodeproj">
</BuildableReference>
</MacroExpansion>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "99BCDCA018008C0000B8E66B"
BuildableName = "TableViewCellWithAutoLayout.app"
BlueprintName = "TableViewCellWithAutoLayout"
ReferencedContainer = "container:TableViewCellWithAutoLayout.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "99BCDCA018008C0000B8E66B"
BuildableName = "TableViewCellWithAutoLayout.app"
BlueprintName = "TableViewCellWithAutoLayout"
ReferencedContainer = "container:TableViewCellWithAutoLayout.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>TableViewCellWithAutoLayout.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>99BCDCA018008C0000B8E66B</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>99BCDCBB18008C0000B8E66B</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>
@@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0500"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "99BCDCA018008C0000B8E66B"
BuildableName = "TableViewCellWithAutoLayout.app"
BlueprintName = "TableViewCellWithAutoLayout"
ReferencedContainer = "container:TableViewCellWithAutoLayout.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
buildConfiguration = "Debug">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "99BCDCBB18008C0000B8E66B"
BuildableName = "TableViewCellWithAutoLayoutTests.xctest"
BlueprintName = "TableViewCellWithAutoLayoutTests"
ReferencedContainer = "container:TableViewCellWithAutoLayout.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "99BCDCA018008C0000B8E66B"
BuildableName = "TableViewCellWithAutoLayout.app"
BlueprintName = "TableViewCellWithAutoLayout"
ReferencedContainer = "container:TableViewCellWithAutoLayout.xcodeproj">
</BuildableReference>
</MacroExpansion>
</TestAction>
<LaunchAction
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "99BCDCA018008C0000B8E66B"
BuildableName = "TableViewCellWithAutoLayout.app"
BlueprintName = "TableViewCellWithAutoLayout"
ReferencedContainer = "container:TableViewCellWithAutoLayout.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
buildConfiguration = "Release"
debugDocumentVersioning = "YES">
<BuildableProductRunnable>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "99BCDCA018008C0000B8E66B"
BuildableName = "TableViewCellWithAutoLayout.app"
BlueprintName = "TableViewCellWithAutoLayout"
ReferencedContainer = "container:TableViewCellWithAutoLayout.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>TableViewCellWithAutoLayout.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>99BCDCA018008C0000B8E66B</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>99BCDCBB18008C0000B8E66B</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>
Binary file not shown.
@@ -0,0 +1,53 @@
{
"images" : [
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
@@ -0,0 +1,51 @@
{
"images" : [
{
"orientation" : "portrait",
"idiom" : "iphone",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"scale" : "2x"
},
{
"orientation" : "portrait",
"idiom" : "iphone",
"subtype" : "retina4",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"scale" : "2x"
},
{
"orientation" : "portrait",
"idiom" : "ipad",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"scale" : "1x"
},
{
"orientation" : "landscape",
"idiom" : "ipad",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"scale" : "1x"
},
{
"orientation" : "portrait",
"idiom" : "ipad",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"scale" : "2x"
},
{
"orientation" : "landscape",
"idiom" : "ipad",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Oops, something went wrong.

1 comment on commit bde387b

@loksurya

This comment has been minimized.

loksurya commented on bde387b May 21, 2015

Hi Tyler, I am implementing a tableview with 3 labels in cell using purelayout, I have used your example code and added few lines of code. I am getting this error
""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:0x1740908b0 'UIView-Encapsulated-Layout-Height' V:[UITableViewCellContentView:0x17419eed0(44)]>",
"<NSLayoutConstraint:0x17008f050 V:|-(5)-[UIView:0x17419efa0]   (Names: '|':UITableViewCellContentView:0x17419eed0 )>",
"<NSLayoutConstraint:0x17008f190 UIView:0x17419efa0.bottom == UITableViewCellContentView:0x17419eed0.bottom - 5>",
"<NSLayoutConstraint:0x17008f280 V:|-(10)-[UILabel:0x124e13c60'Marion']   (Names: '|':UIView:0x17419efa0 )>",
"<NSLayoutConstraint:0x17008f370 V:[UILabel:0x124e13c60'Marion']-(>=10)-[UILabel:0x124e13fc0'42324']>",
"<NSLayoutConstraint:0x17008f460 V:[UILabel:0x124e13fc0'42324']-(>=10)-[UILabel:0x124e14120'Lorem ipsum dolor sit ame...']>",
"<NSLayoutConstraint:0x17008f5a0 UILabel:0x124e14120'Lorem ipsum dolor sit ame...'.bottom == UIView:0x17419efa0.bottom - 10>"

)

Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x17008f370 V:[UILabel:0x124e13c60'Marion']-(>=10)-[UILabel:0x124e13fc0'42324']>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger. ""

I am not able to figure out the error, I think all my constraints are compulsory, point out where I can be wrong
My code is

  • (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
    {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {

    self.contView = [UIView newAutoLayoutView];
    
    self.titleLabel = [UILabel newAutoLayoutView];
    [self.titleLabel setLineBreakMode:NSLineBreakByTruncatingTail];
    [self.titleLabel setNumberOfLines:1];
    [self.titleLabel setTextAlignment:NSTextAlignmentLeft];
    [self.titleLabel setTextColor:[UIColor blackColor]];
    self.titleLabel.backgroundColor = [UIColor colorWithRed:0 green:0 blue:1 alpha:0.1];
    
    self.constLabel = [UILabel newAutoLayoutView];
    [self.constLabel setLineBreakMode:NSLineBreakByTruncatingTail];
    [self.constLabel setNumberOfLines:1];
    [self.constLabel setTextAlignment:NSTextAlignmentLeft];
    [self.constLabel setTextColor:[UIColor blackColor]];
    self.constLabel.backgroundColor = [UIColor colorWithRed:0 green:0 blue:1 alpha:0.1];
    
    self.bodyLabel = [UILabel newAutoLayoutView];
    [self.bodyLabel setLineBreakMode:NSLineBreakByTruncatingTail];
    [self.bodyLabel setNumberOfLines:0];
    [self.bodyLabel setTextAlignment:NSTextAlignmentLeft];
    [self.bodyLabel setTextColor:[UIColor darkGrayColor]];
    self.bodyLabel.backgroundColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:0.1];
    
    self.contentView.backgroundColor = [UIColor colorWithRed:0 green:1 blue:0 alpha:0.1];
    
    [self.contView addSubview:self.titleLabel];
    [self.contView addSubview:self.bodyLabel];
    [self.contView addSubview:self.constLabel];
    
    [self.contentView addSubview:self.contView];
    [self updateFonts];
    

    }

    return self;
    }

  • (void)updateConstraints
    {
    if (!self.didSetupConstraints) {
    // Note: if the constraints you add below require a larger cell size than the current size (which is likely to be the default size {320, 44}), you'll get an exception.
    // As a fix, you can temporarily increase the size of the cell's contentView so that this does not occur using code similar to the line below.
    // See here for further discussion: bde387b#commitcomment-4633188
    // self.contentView.bounds = CGRectMake(0.0f, 0.0f, 99999.0f, 99999.0f);

    [self.contView autoPinEdgesToSuperviewEdgesWithInsets:UIEdgeInsetsMake(5, 5, 5, 5)];
    
    /*[UIView autoSetPriority:UILayoutPriorityRequired forConstraints:^{
        [self.titleLabel autoSetContentCompressionResistancePriorityForAxis:ALAxisVertical];
    }];*/
    [self.titleLabel autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:kLabelVerticalInsets];
    [self.titleLabel autoPinEdgeToSuperviewEdge:ALEdgeLeading withInset:kLabelHorizontalInsets];
    [self.titleLabel autoPinEdgeToSuperviewEdge:ALEdgeTrailing withInset:kLabelHorizontalInsets];
    
    
    [self.constLabel autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:self.titleLabel withOffset:kLabelVerticalInsets relation:NSLayoutRelationGreaterThanOrEqual];
    [self.constLabel autoPinEdgeToSuperviewEdge:ALEdgeLeading withInset:kLabelHorizontalInsets];
    [self.constLabel autoPinEdgeToSuperviewEdge:ALEdgeTrailing withInset:kLabelHorizontalInsets];
    
    
    // This is the constraint that connects the title and body labels. It is a "greater than or equal" inequality so that if the row height is
    // slightly larger than what is actually required to fit the cell's subviews, the extra space will go here. (This is the case on iOS 7
    // where the cell separator is only 0.5 points tall, but in the tableView:heightForRowAtIndexPath: method of the view controller, we add
    // a full 1.0 point in extra height to account for it, which results in 0.5 points extra space in the cell.)
    // See https://github.com/smileyborg/TableViewCellWithAutoLayout/issues/3 for more info.
    [self.bodyLabel autoPinEdge:ALEdgeTop toEdge:ALEdgeBottom ofView:self.constLabel withOffset:kLabelVerticalInsets relation:NSLayoutRelationGreaterThanOrEqual];
    
    /*[UIView autoSetPriority:UILayoutPriorityRequired forConstraints:^{
        [self.bodyLabel autoSetContentCompressionResistancePriorityForAxis:ALAxisVertical];
    }];*/
    [self.bodyLabel autoPinEdgeToSuperviewEdge:ALEdgeLeading withInset:kLabelHorizontalInsets];
    [self.bodyLabel autoPinEdgeToSuperviewEdge:ALEdgeTrailing withInset:kLabelHorizontalInsets];
    [self.bodyLabel autoPinEdgeToSuperviewEdge:ALEdgeBottom withInset:kLabelVerticalInsets];
    
    self.didSetupConstraints = YES;
    

    }

    [super updateConstraints];
    }

  • (void)layoutSubviews
    {
    [super layoutSubviews];

    // Make sure the contentView does a layout pass here so that its subviews have their frames set, which we
    // need to use to set the preferredMaxLayoutWidth below.
    [self.contentView setNeedsLayout];
    [self.contentView layoutIfNeeded];

    // Set the preferredMaxLayoutWidth of the mutli-line bodyLabel based on the evaluated width of the label's frame,
    // as this will allow the text to wrap correctly, and as a result allow the label to take on the correct height.
    self.bodyLabel.preferredMaxLayoutWidth = CGRectGetWidth(self.bodyLabel.frame);
    }

  • (void)updateFonts
    {
    self.titleLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleHeadline];
    self.constLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleCaption2];
    self.bodyLabel.font = [UIFont preferredFontForTextStyle:UIFontTextStyleCaption2];
    }

Please sign in to comment.