Custom UITableViewCell in XCode 4 - connecting outlets?
Ok, this should be a piece of cake.
I want to create a reusable UITableViewCell which is a simple UITextView so I can have a resizable cell for different length text, which wraps.
Simple, Eh?
I can create the .h and .m file just fine, and I can create an .xib file.
Apparently, someone at Apple decided that the template for UITableViewCell doesn't come with a .xib file.
Now, when I try what I think I'm supposed to do, to make the connection between my UITextView field, the ONLY outlet available is 'delegate'.
Can someone either tell me what I'm doing wrong, or how this is supposed to work.
ProfileSummaryCell.h
// ProfileSummaryCell.h
#import <UIKit/UIKit.h>
@interface ProfileSummaryCell : UITableViewCell {
IBOutlet UITextView *summaryTextView;
}
@end
ProfileSummaryCell.m
// ProfileSummaryCell.m
#import "ProfileSummaryCell.h"
@implementation ProfileSummaryCell
- (UITextView *) getSummaryTextView {
returnsummaryTextView;
}
- (void) setSummaryTextView: (UITextView *) textView {
summaryTextView = textView;
[selfsetNeedsDisplay];
}
@end
To create the xib file, I create the file as an empty container, and drag a UITableViewCell object to the canvas, and set the class and reuse identifier both to "ProfileSummaryCell", then drag a UITextView object and center it in the ProfileSummaryCell object, then set top and side margins.
I try to control-click from the summaryTextView field in my ProfileSummaryCell object in the .xib file and drag to File's Owner and the pop-up says there's only one outlet: 'delegate'.
Going the other way, there's nothing... no pop-up, so it's ignored.
If I select the ProfileSummaryCell object then in the connections list it shows the normal things, and it shows my 'summaryTextView' field. However, again, the only outlet that shows up on the File's Owner is 'delegate'.
THIS SHOULD BE SO SIMPLE!!! (And yes, I'm yelling, because it is driving me crazy).
I have also gone to the Assistant Editor window and set the "assocoated files" to Automatic (2): ProfileSummaryCell.h/.m, and also tried it manually.
I've also tried building a UITableViewController class object which does create .h, .m, and .xib and then changed the class to ProfileSummaryCell : UITableViewCell by hand and removed and re-added the correct bits to look like the .h/.m above and the 2 elements in the .xib file as above.
No change in the behavior.
It won't let me connect the UITextView object to the IBOutlet, nor does it even show the IBOutlet as a possible connection.
I've also tried adding the appropriate @property and @synthesize statements for summaryTextView, which takes away the ability to use setNeedsDisplay, but even that didn't work. Same results.
Am I doing something wrong? (Some simple newbie mistake?)
Is XCode broken?
Can someone replicate the code from above, and figure out how to make it work and tell me?
Thanks!