UITableViewCell accessoryView not displaying?

You are setting your accessoryView to be a label so you're not going to see any disclosure indicator. If you want title and detail text in your cell then init it with UITableViewCellStyleValue2 like this...

Up vote 1 down vote favorite share g+ share fb share tw.

Im totally unsure why my accessory view is not working. I simply want some text to appear to the right of the UITableViewCell (as well as the left), but only the text on the left is displaying. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell* cell = tableView dequeueReusableCellWithIdentifier:@"SwitchCell"; if (cell==nil){ cell = UITableViewCell alloc initWithFrame:CGRectZero reuseIdentifier:@"SwitchCell" autorelease; UILabel *label = UILabel alloc initWithFrame:CGRectMake(5, 0, 60, 30); cell.textLabel.

Text = @"left text"; label. Text = @"right text"; cell. AccessoryType = UITableViewCellAccessoryDisclosureIndicator; cell.

AccessoryView = label; label release; } return cell; } Any ideas? Thanks. Iphone cocoa-touch uitableviewcell accessoryview link|improve this question asked Jun 14 '11 at 13:19Andy A168111 95% accept rate.

I suggest you give label alignment to right first. By default label alignment must be left. So two texts one on top of the other could be the problem.

And then you can just say: cell. ContentView addSubView:label; – Mike JM Jun 14 '11 at 13:25.

Cell. AccessoryView = label; You are setting your accessoryView to be a label so you're not going to see any disclosure indicator. If you want title and detail text in your cell then init it with UITableViewCellStyleValue2 like this... cell = UITableViewCell alloc initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:@"cellType" autorelease; ...and then set the title and detail like this... cell.textLabel.

Text = "Title; cell.detailTextLabel. Text = "Description"; To get an idea of the different built in table styles check the following image... You can adjust the textLabel and detailTextLabel to suit your taste.

While this doesn't answer my question directly (I have a UILabel working as an accessoryView elsewhere in my app, so Im not sure why its not working here), you have certainly provided me with some great alternatives. The main concern I have, though, is that the text gets truncated. Is there no way around this (unless I use my own custom cell)?

– Andy A Jun 14 '11 at 14:47 These alternatives, I have concluded, were the correct way to go. – Andy A Jun 22 '11 at 9:36.

(id)initWithFrame:(CGRect)frame reuseIdentifier:(NSString *)reuseIdentifier was depreciated in iOS 3.0 Instead use: -(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier Pass in either UITableViewCellStyleValue1 or UITableViewCellStyleValue2 and set the textLabel and detailTextLabel properties as you need. http://developer.apple.com/library/ios/#documentation/uikit/reference/UITableViewCell_Class/Reference/Reference.html%23//apple_ref/doc/uid/TP40006938-CH3-SW34.

You can't have both. Cell. AccessoryType = UITableViewCellAccessoryDisclosureIndicator.

True. My mistake. But nevertheless, my question still stands if you take out that line of code.

– Andy A Jun 15 '11 at 8:47.

Try by adding self. View addSubview: accessoryView.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions