views:

44

answers:

1

I want to create a tableviewcell and add it on the view(not tableview) as

CGRect aframe=CGRectMake( 20, 20, 200, 200);
UITableViewCell *cell =[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
cell.frame=aframe;
[self.view addSubview:cell];

But this is not working at all. Can't we create cell independently and add to our view

+3  A: 

UITableViewCell is meant to be used in a UITableView. I would imagine that there are things happening under the hood in UITableViewCell that assume that it's operating in a UITableView. Even if you were able to get this to work, I would expect it to be pretty fragile and vulnerable to breaking during OS updates, again, because it was written with the assumption of being embedded in a UITableView.

Alex
Alex is probably right. I could imagine it had, at least, some "should display" - "should cache" methods that needs to be called from a UITableView acting as a delegate.
RickiG