last day (14 days later) » 

10:26
1
A: Increase height of tableview cell according to amount of UILabel text

YatendraTry with this... it will help you. NSString *classSubjecttxt =@"Some text"; CGSize requiredSizeSubjetc =[classSubjecttxt sizeWithFont:[UIFont fontWithName:@"Trebuchet MS" size:12] constrainedToSize:CGSizeMake(SCREEN_WIDTH-labelwidth, CGFLOAT_MAX)]; int height=YOUR DEFAULT HEIGHT; ...

can we calculate the value, which is 18 right now in this code : height=height-18+ceil(requiredSizeSubjetc.height);
18 is nothing it's labelheight
I am using your code.. it adds some white spaces in some cells which is not in my requirements.
Actually it adds white spaces in all those cells whose height is greater than 18. And it fails if the label size is greater than 200.
Have you set correct parameter in you code ? Please check your code again
one more thing after it you need to set frame in cellforrowatindexpath method
Here is my code: int height=53.0; if(requiredSizeSubjetc.height >42){ height=height-20+ceil(requiredSizeSubjetc.height); } return height; }
10:26
42 and 20 should be same
42 or 20
Actually i have dynamic text means mat b it contains 2 latters or it may contain 24 lines
so i have to calculate the exact height for each cell according to their text
yeah,but i want to say that your label height here should be same,after calculation it will increased.so plz try with 20.
I have tried it with 20 but it add extra white spaces in all those cells whose height >20
have you set frame in cellforrowatindexpath for label which height is more than 20
10:43
I am creating cell in cellforrowatindexpath.. how can i set frame?
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

AddTaskTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"addTaskCell" forIndexPath:indexPath];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
AddTaskDetails *task =[self.tasksArray objectAtIndex:indexPath.row];
NSAttributedString *attributedString = [self attributedTextForTask:task.taskDetail];
cell.taskDetails.attributedText = attributedString;
cell.hourePicker.tag = indexPath.row;
here is the code
Before return cell add this


CGSize requiredSizeSubjetc =[classSubjecttxt sizeWithFont:[UIFont fontWithName:@"Trebuchet MS" size:12] constrainedToSize:CGSizeMake(SCREEN_WIDTH-labelwidth CGFLOAT_MAX)];

if(requiredSizeSubjetc.height >18)
{
cell.ConstHeight_Subject.constant=ceil(requiredSizeSubjetc.height);
}


Here ConstHeight_Subject is height constraint of your label which you can set from Iboutlet
ok let me try
one more thing is that i mistake it SCREEN_WIDTH-labelwidth,
it should be your label width spread on screen
Please change it in both code
what is ConstHeight_Subject?
yes i am changing it
Here ConstHeight_Subject is height constraint of your label which you can set from Iboutlet
using autolayout
fix the height of label
then make Iboutlet of it
10:57
ok
11:19
its not working for me :(
please upload resultent screenshot of your app
11:57
here is the ss
you can see the white space in last 2 items

last day (14 days later) »