ios - my chat system looks a little wierd, cant get dynamic height for cell -


ive got chat system in app, , im attempting make dynamic cells have dynamic height according how text in cell, pretty common thing people try do, cant get mine working properly.

also messages align right, sender supposed on left , reciever should on right... heres have done storyboard.

created tableview 2 dynamic prototypes, inside uiviewcontrollerhere viewcontroller that... each cell has label, 1 left 1 right, whole right , left thing work... heres issue. pulling right all, if isnt happening , else overruling. heres ss.

so have 2 issues... text wont have multiple lines... along wont dynamic height, also... if can point me right dirrection getting sender , reciever show on different sides.

enter image description here

- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath {     nsarray *mywords = [[getmessage objectatindex:indexpath.row] componentsseparatedbystring:@":oyr4:"];     if (mywords[1] == [myclass str]){         static nsstring *sender = @"sender";         uitableviewcell* cellsender = [_tableview dequeuereusablecellwithidentifier:sender];         messagecontentto = (uilabel *)[cellsender viewwithtag:83];         self->messagecontentto.backgroundcolor = [uicolor colorwithwhite:1.0 alpha:0.8];         self->messagecontentto.linebreakmode = nslinebreakbywordwrapping;         [self->messagecontentto sizetofit];         messagecontentto.text = mywords[4];         return cellsender;     } else {          static nsstring *reciever = @"reciever";          uitableviewcell* cellreciever = [_tableview dequeuereusablecellwithidentifier:reciever];         messagecontentfrom = (uilabel *)[cellreciever viewwithtag:84];         messagecontentfrom.backgroundcolor = [uicolor colorwithwhite:1.0 alpha:0.8];         messagecontentfrom.linebreakmode = nslinebreakbywordwrapping;         messagecontentfrom.font = [uifont systemfontofsize:22];         messagecontentfrom.numberoflines = 0;         messagecontentfrom.text = mywords[4];          return cellreciever;     }  } #pragma mark - uitableviewdelegate methods - (cgfloat)tableview:(uitableview *)tableview heightforrowatindexpath:(nsindexpath *)indexpath {     cgsize size = [[getmessage objectatindex:indexpath.row]                    sizewithfont:[uifont systemfontofsize:22]                    constrainedtosize:cgsizemake(1000, cgfloat_max)];     return size.height + 15; } 

the left-right problem might due this:

if (mywords[1] == [myclass str]) 

if mywords[1] string, need use isequaltostring: not "==" compare it.

if ([mywords[1] isequaltostring:[myclass str]]) 

as far label height not adjusting properly, it's hard tell what's going on without knowing how labels set up. making constraints between label , top , bottom of cell in ib. way, when change height of cell, label follow (and of course, set numberoflines 0). also, in sizewithfont:constrainedtosize: method, width pass cgsizemake() should width of label, not 1000.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -