0

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

1 Answer 1

4

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.

Sign up to request clarification or add additional context in comments.

1 Comment

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.