Moshe
Moshe

Reputation: 58087

Custom UITableViewCell for Settings-like application?

I'd like to have a settings view in my app. I want to have things like UILabels, UISwitches etc. (Like in the Settings app.)

How can I go about doing that? Can I just replace the detailView with the required view, or is there more to it then that? That may not work because I need to be able to set and get text values too.

Upvotes: 0

Views: 1251

Answers (2)

Sorig
Sorig

Reputation: 1211

You just add your custom views as subviews to the cells content view. Heres an example with an image view:

UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 30, 30)];
imageView.image = [UIImage imageNamed:@"SomeImage.png"];
[cell.contentView addSubview:imageView];

Upvotes: 0

Joseph Tura
Joseph Tura

Reputation: 6360

Take a look at this project.

If you want to do it yourself, you can e.g. attach your own views to the cell's contentView, or use the accessory view to display your switches etc.

Upvotes: 1

Related Questions