Custom UITableViewCell for Settings-like application?

我与影子孤独终老i 提交于 2019-12-25 04:45:15

问题


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.


回答1:


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.




回答2:


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];


来源:https://stackoverflow.com/questions/4063731/custom-uitableviewcell-for-settings-like-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!