ios - Adjusting Cell fields - Objective C -
i have dynamically set table view controller
used populate news type feed. having trouble connecting 1 class other setting text, image, etc... of current cell.
here gist:
- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *cellidentifier = @"timelinecell"; fbgtimelinecell *cell = (fbgtimelinecell *)[tableview dequeuereusablecellwithidentifier:cellidentifier]; cell.text = [self.googleplacesarrayfromafnetworking[indexpath.row] objectforkey:@"message"]; <!-- here want example, set title message within array. if (!cell) { cell = [[fbgtimelinecell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:cellidentifier]; [cell setselectionstyle:uitableviewcellselectionstylenone]; [cell inittimelinecell]; } uiimage *img = [uiimage imagenamed:[nsstring stringwithformat:@"%d.jpg", indexpath.row]]; cell.photoview.image = img; return cell; }
here fbh... init
function:
- (id)initwithstyle:(uitableviewcellstyle)style reuseidentifier:(nsstring *)reuseidentifier { self = [super initwithstyle:style reuseidentifier:reuseidentifier]; if (self) { // initialization code cellcontentview = [[uiview alloc] initwithframe:cgrectmake(10, 5, 300, 440)]; cellcontentview.backgroundcolor = [uicolor whitecolor]; photoview = [[fbgtimelinephotoview alloc] initwithframe:cgrectmake(5, 102, 310, 310)]; photoview.backgroundcolor = [uicolor darkgraycolor]; [photoview setuserinteractionenabled:yes]; uiview *profilepic = [[uiview alloc] initwithframe:cgrectmake(9, 9, 30, 30)]; profilepic.backgroundcolor = [uicolor darkgraycolor]; uilabel *usernamelabel = [[uilabel alloc] initwithframe:cgrectmake(45, 9, 222, 18)]; usernamelabel.font = [uifont systemfontofsize:14.0]; usernamelabel.text = @"username"; uilabel *timestamplabel = [[uilabel alloc] initwithframe:cgrectmake(45, 25, 222, 17)]; timestamplabel.font = [uifont systemfontofsize:12.0]; timestamplabel.text = @"3 hours ago"; timestamplabel.textcolor = [uicolor lightgraycolor]; uilabel *statuslabel = [[uilabel alloc] initwithframe:cgrectmake(9, 50, 283, 41)]; statuslabel.font = [uifont systemfontofsize:15.0]; statuslabel.text = @"status..status..status..status..status..status..status..status..status..status..status..status..status..status..status.."; statuslabel.numberoflines = 2; statuslabel.linebreakmode = nslinebreakbywordwrapping; uilabel *likelabel = [[uilabel alloc] initwithframe:cgrectmake(9, 413, 32, 21)]; likelabel.font = [uifont systemfontofsize:13.0]; likelabel.text = @"like"; uilabel *commentlabel = [[uilabel alloc] initwithframe:cgrectmake(113, 413, 74, 21)]; commentlabel.font = [uifont systemfontofsize:13.0]; commentlabel.text = @"comment"; uilabel *sharelabel = [[uilabel alloc] initwithframe:cgrectmake(246, 413, 46, 21)]; sharelabel.font = [uifont systemfontofsize:13.0]; sharelabel.text = @"share"; [self addsubview:cellcontentview]; [self addsubview:photoview]; [cellcontentview addsubview:profilepic]; [cellcontentview addsubview:usernamelabel]; [cellcontentview addsubview:timestamplabel]; [cellcontentview addsubview:statuslabel]; [cellcontentview addsubview:likelabel]; [cellcontentview addsubview:commentlabel]; [cellcontentview addsubview:sharelabel]; } return self; }
so need able set cell text , different views within cell within cellforrowatindexpath
if possible each cell set in fb..init
function.
suggestions, thoughts?
you should create properties (in fbgtimelinecell class) each of ui elements need access in cellfrorowatindexpath, can access them cell.propertyname.
Comments
Post a Comment