• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Storyboard won't instantiate my class
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Storyboard won't instantiate my class


  • Subject: Storyboard won't instantiate my class
  • From: Rick Aurbach <email@hidden>
  • Date: Thu, 13 Feb 2014 16:53:48 -0500
  • Acceptlanguage: en-US
  • Thread-topic: Storyboard won't instantiate my class

This problem involves Storyboards (no XIBs) in an iOS7 application implemented in Xcode 5.0.2.

I have a UITableView which contains a cell prototype which includes a custom UILabel subclass. However, when I instantiate a cell using this cell prototype, the object instantiated in cell’s contentView is a UILabel, not my custom subclass.

None of my subclass methods is called.

Here is the relevant section of the storyboard:

    <tableViewCell contentMode="scaleToFill" selectionStyle="none" 
                hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" 
                reuseIdentifier="TappableLabelCell" rowHeight="36" id="Gny-Z4-398">
        <rect key="frame" x="0.0" y="157" width="320" height="36"/>
        <autoresizingMask key="autoresizingMask"/>
        <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" 
                multipleTouchEnabled="YES" contentMode="center" tableViewCell="Gny-Z4-398" 
                id="XhW-zd-BfE">
            <rect key="frame" x="0.0" y="0.0" width="320" height="36"/>
            <autoresizingMask key="autoresizingMask"/>
            <subviews>
                <label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" tag="1" 
                        contentMode="left" horizontalHuggingPriority="251" 
                        verticalHuggingPriority="251" fixedFrame="YES" text="tap to choose" 
                        lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" 
                        adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" 
                        id="Bpv-bz-HXh" customClass="AATappableLabel">
                    <rect key="frame" x="20" y="7" width="280" height="21"/>
                    <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
                    <fontDescription key="fontDescription" style="UICTFontTextStyleBody"/>
                    <color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
                    <nil key="highlightedColor"/>
                </label>
            </subviews>
        </tableViewCellContentView>
    </tableViewCell>

And just to be thorough, AATappableLabel.h looks like:

@interface AATappableLabel : UILabel

@property (strong, nonatomic) NSString * placeholder;
@property (strong, nonatomic) NSString * identifier;
@property (weak, nonatomic) id <AATappableLabelDelegate> delegate;

- (BOOL)hasText;

@end

Notice that the storyboard recognizes that the label ought to instantiate a custom class (see red text above), but that doesn’t happen
  • if I set breakpoints in the initxxx methods, they are never hit
  • if I break in the method where the cell is instantiated, the debugger identifies the object as a UILabel, rather than an AATappableLabel.
  • Attempting to use an of AATappableLabel’s unique methods causes the expected exception.

Can anyone offer an idea about why this is happening? It looks like a bug to me, but I thought I’d see if anybody could point out a particularly stupid mistake that I’m making before I submit either an ADC incident or a Bug Report.

Thanks.

Cheers,

Rick Aurbach
Aurbach & Associates, Inc.

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Storyboard won't instantiate my class
      • From: Kyle Sluder <email@hidden>
    • Re: Storyboard won't instantiate my class
      • From: Kyle Sluder <email@hidden>
  • Prev by Date: Re: Where to report this clang issue?
  • Next by Date: Re: Where to report this clang issue?
  • Previous by thread: Re: Where to report this clang issue?
  • Next by thread: Re: Storyboard won't instantiate my class
  • Index(es):
    • Date
    • Thread