Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

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!

Posted on Feb 2, 2012 1:15 AM

Reply
Question marked as Best reply

Posted on Feb 2, 2012 1:47 AM

Oh, by the way, I previously had a problem like this, and solved it by fixing the class name of the File's Owner.

That is not a problem here. Below is a screen shot that shows the outlet exists in at least one selectable list, but I do not seem to be able to click and drag to make the connection.


User uploaded file

Thanks in advance for any help. Or things I may have overlooked.

2 replies
Question marked as Best reply

Feb 2, 2012 1:47 AM in response to reststop

Oh, by the way, I previously had a problem like this, and solved it by fixing the class name of the File's Owner.

That is not a problem here. Below is a screen shot that shows the outlet exists in at least one selectable list, but I do not seem to be able to click and drag to make the connection.


User uploaded file

Thanks in advance for any help. Or things I may have overlooked.

Feb 2, 2012 7:43 PM in response to reststop

I'm still not sure if this is the answer, but it seems that after much trial and error, and head banging, control-click on the File's Owner to the selected summaryTextView field DOES indeed work. It just looks funny with the connection seemingly to itself, because the field name and the text name of the UITextView match.


User uploaded file

User uploaded file


Go figure!

Why does this all seem like pulling teeth to do something simple?


And WHY didn't this just work the first time?

Custom UITableViewCell in XCode 4 - connecting outlets?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.