Custom UITableViewCell for Settings-like application?
I'd like to have a setti开发者_JS百科ngs 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.
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.
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];
精彩评论