I have made a custom UITableViewCell
which has elements like label and a segmentcontrol
But when i try to access the elements in the cellforrowatindexpath
the elements are not allocated any memory . the cell instance has been allocated memory . i have checked the xib and connected the outlets. Here is the code in the cellforrowatindexpath
-
SegmentCell *cell;
[tableView registerNib:[UINib nibWithNibName:@"SegmentCell" bundle:nil] forCellReuseIdentifier:@"SegmentCell"];
[tableView registerClass:[SegmentCell class] forCellReuseIdentifier:@"SegmentCell"];
cell = (SegmentCell *)[tableView dequeueReusableCellWithIdentifier:@"SegmentCell" forIndexPath:indexPath];
cell.title.text=@"Hell*emphasized text*o";
return cell;
The title is the label which shows nil in print description
UITableViewCell's title
is a deprecated property of type NSString, not UILabel. Use the titleLabel
property instead.
cell.titleLabel.text = @"whatever";
Since title
is a property of your custom class SegmentCell , you are responsible to allocate an instance of UILabel and assign it to title. If it is included in your Nib file, be sure it is bound to the class property.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.