last day (14 days later) » 

10:54
0
Q: Only first cell appears initially in UITableView, the rest appear after scrolling

PacemakerI am going crazy over this seemingly simple task that is messing up. I have a UItableView with a custom cell. Inside the cell, I have only 1 label that can have different heights (depending on content) I am using Auto Layout for that. I set the top, bottom, left, right constraints to the cell's...

leave the 4 constraints and in viewDidLoad do the following: tableView.estimatedRowHeight = 44.0 and tableView.rowHeight = UITableViewAutomaticDimension (where tableView is the name of your tableview and 44.0 and estimated value - change it to what suits you)
@AndreSlotta I am doing that. Ashok , Which part exactly should I be looking at?
and you do not have heightforrowatindexpath implemented, do you?
@AndreSlotta No, I do not know how to calculate the height from UILabel. But why is it that when i add the bottom constraint, the other cells shrink?
@Pacemaker could you maybe share your project to take a look whats going wrong?
10:54
@AndreSlotta It's a big project, what exactly do you think you need to see?
actually only the problematic viewcontroller in a storyboard and the viewcontrollers class of course...
@AndreSlotta check out the edit, thanks
aren't you using storyboards?
Hi andre, thanks for your interest
here we ware
10:54
I am not using story boards
ah ok, that is what i guessed...
It is really weird because the layout is dead simple. Just a UILabel that needs to stretch based on content
i did not setup automatic tableviewcell height without storyboards yet... but i will take a look
After scroll, some cells show up nicely. I have put the borders to check what is happening
Some cells are overlapping
oh wait...
you are using a custom cell, right?
11:00
yes
In case I will be adding metadata like a time stamp
ok, but in cellforrow you are using textlabel property which belongs to the standard label...
so you are not working with your custom label
forget what i said
can you show me your cellforrow implementation?
I am initializing the custom cell I have
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
NSString *CellIdentifier = [NSString stringWithFormat:@"id2"];
CommentTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(!cell){
[tableView registerNib:[UINib nibWithNibName:@"CommentCell" bundle:nil] forCellReuseIdentifier:CellIdentifier];
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
CommentObject *comment = [_data objectAtIndex:indexPath.row];
where text is the UILabel
Are you able to re-create the same problem?
11:21
1. put that tableview registernib method in your viewdidload
then your cellforrow method should look like this:
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
NSString *CellIdentifier = [NSString stringWithFormat:@"id2"];
CommentTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];


return cell;

}
oh
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
NSString *CellIdentifier = [NSString stringWithFormat:@"id2"];

CommentTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
CommentObject *comment = [_data objectAtIndex:indexPath.row];
cell.text.text = comment.text;

return cell;

}
the last one is correct
What is the first point you made?
override func viewDidLoad() {
super.viewDidLoad()

tableView.registerNib(UINib(nibName: "CustomCell", bundle: nil), forCellReuseIdentifier: "Cell")
}
put that registernib call in your viewdidload
and instead of [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; use [tableView dequeueReusableCellWithIdentifier:CellIdentifier forindexpath.... method
Errors:
1-) property registernib not found on object type UITableView
2-) use of undeclared identifier nibname, did you mean _nibname
[tableView registerNib:[UINib nibWithNibName:@"CommentCell" bundle:nil] forCellReuseIdentifier:@"id2"];
Now cells don't appear initially, but appear after scroll.. still some overlapping
Where do you suspect the problem is? rendering? creating cell objects?
11:32
well... i set up a project like yours and everything works :) somethings gotta be wrong in your code... but that could be everywhere... hard to say without seeing the complete code
Okay, well thanks for your time and effort. I will keep looking
you're welcome
but one question, what exactly did you do with the following code?
I suspect it is a problem of auto layout, not the way UiTableView manages it's views. Because when I remove the bottom constraints, they appear !
but i use a custom cell with all four constraints and everything works as expected
so i think that you are doing something wrong somewhere
are you working with the simulator or a real device?
real device, iPhone 4s
11:36
iOS 7?
iOs 8
I will keep looking using your suggestions.. Thanks a bunch.. Take care friend
i will give you a link in a second...
take a look at my project:
i hope it helps
 
3 hours later…
14:51
i am new in cordova with ios
my requirement send lattitude and longitude in server background every minutes
iam trying christocracy background but not working

last day (14 days later) »