我试图利用 ABPersonViewController 的简单性,同时稍微定制它的外观以匹配我的应用程序的外观和感觉。
我将 ABPersonViewController 子类化,并使用这种技术,循环遍历 ABPersonViewController 的视图层次结构,这是我的输出:
UIView:0x5a45d80;帧 = (0 0; 320 416); 自动调整大小 = W+H;层=> | ABPersonTableView: 0x6041a00; 基类 = UITableView; 帧 = (0 0; 320 416); clipsToBounds = YES; 自动调整大小 = W+H;层 = ; 内容偏移:{0, 0}> | | ABMultiCell:0x5a50080;基类 = UITableViewCell; 帧 = (0 94; 320 45); 自动调整大小 = W;标签 = 10; 层=> | | | UIGroupTableViewCellBackground: 0x5a678d0; 帧 = (9 0; 302 45); 自动调整大小 = W;层=> | | | UITableViewCellContentView: 0x5a62670; 帧 = (10 1; 300 43); 层=> | | | | ABMultiCellContentView_Simple:0x5a4fef0;帧 = (0 0; 300 43); 文字='(555)555-5555';clipsToBounds = YES; 层=> | | | | | UILabel: 0x5a61590; 帧 = (5 14.54; 70 16); 文字='手机'; clipsToBounds = YES; 用户交互启用 = 否;层=> | | | | | ABDividerView:0x5a62ff0;帧 = (79 0; 1 44); 阿尔法 = 0; 层=> | | | | | | ABSteadfastLineView: 0x5a53ab0; 帧 = (0 0; 1 44); 层=> | | | | | ABHighlightingTextField:0x5a53c30;基类 = UITextField; 帧 = (85 12; 210 21); 文字='(555)555-5555';clipsToBounds = YES; 不透明=否;用户交互启用 = 否;层=> | | | | | | UITextFieldLabel: 0x5a53db0; 帧 = (0 0; 210 19); 文字='(530)305-0835';clipsToBounds = YES; 不透明=否;用户交互启用 = 否;层=> | | UIView:0x5a5b300;帧 = (0 0; 320 94); 层=> | | | ABPersonTableHeaderView: 0x5a444b0; 帧 = (0 0; 320 94); clipsToBounds = YES; 自动调整大小 = W;层=> | | | | ABPersonImageView:0x5a449c0;基类 = UIControl; 帧 = (19 15; 64 64); clipsToBounds = YES; 自动调整大小 = RM+BM;层=> | | | | | ABClippingImageView: 0x5a6aae0; 帧 = (0 0; 64 64); 不透明=否;用户交互启用 = 否;层=> | | | | | ABImageWellLabelView: 0x5a6c0b0; 帧 = (0 0; 64 64); 阿尔法 = 0; 不透明=否;用户交互启用 = 否;层=> | | | | ABPersonNameEditingViewContainer: 0x5a4a9e0; 帧 = (101 15; 530 64); 阿尔法 = 0; 自动调整大小 = W+BM;层=> | | | | | ABMultiCellContentView_Name:0x5a4b480;帧 = (1 0; 208 64); clipsToBounds = YES; 层=> | | | | | | ABHighlightingTextField:0x5a4d7c0;基类 = UITextField; 帧 = (-5 12; 10 21); 文本 = '名字'; clipsToBounds = YES; 不透明=否;用户交互启用 = 否;标签 = 1; 层=> | | | | | | | UITextFieldLabel: 0x5a4b3e0; 帧 = (-10 0; 10 19); 文本 = '名字'; clipsToBounds = YES; 不透明=否;用户交互启用 = 否;层=> | | | | | | ABHighlightingTextField:0x5a50a90;基类 = UITextField; 帧 = (-5 56; 10 21); text = '姓氏'; clipsToBounds = YES; 不透明=否;用户交互启用 = 否;标签 = 2; 层=> | | | | | | | UITextFieldLabel: 0x5a4e5d0; 帧 = (-10 0; 10 19); text = '姓氏'; clipsToBounds = YES; 不透明=否;用户交互启用 = 否;层=> | | | | | | ABDividerView:0x5a52300;帧 = (0 44; 0 1); 层=> | | | | | | | ABSteadfastLineView: 0x5a525d0; 帧 = (0 0; 0 1); 层=> | | | | | | ABHighlightingTextField:0x5a52400;基类 = UITextField; 帧 = (-5 100; 10 21); clipsToBounds = YES; 不透明=否;用户交互启用 = 否;标签 = 3; 层=> | | | | | | | UITextFieldLabel: 0x5a5a4e0; 帧 = (-8 0; 10 19); 文本 = '公司'; clipsToBounds = YES; 不透明=否;用户交互启用 = 否;层=> | | | | | | ABDividerView:0x5a53f00;帧 = (0 88; 0 1); 层=> | | | | | | | ABSteadfastLineView: 0x5a53f80; 帧 = (0 0; 0 1); 层=> | | | | ABPersonNameDisplayView: 0x5a45cf0; 基类 = UIControl; 帧 = (97 15; 204 64); 自动调整大小 = W;层=> | | | | | UILabel: 0x5a4bbd0; 帧 = (0 21; 109 23); text = '名字姓氏'; clipsToBounds = YES; 自动调整大小 = W;用户交互启用 = 否;层=> | | | | | UILabel: 0x5a4c020; 帧 = (0 0; 204 0); clipsToBounds = YES; 自动调整大小 = W;用户交互启用 = 否;层=> | | UIImageView:0xcc032a0;帧 = (0 409; 320 7); 阿尔法 = 0; 不透明=否;自动调整大小 = TM;用户交互启用 = 否;层=> | | UIImageView: 0xcc03350; 帧 = (313 262; 7 154); 阿尔法 = 0; 不透明=否;自动调整大小 = LM; 用户交互启用 = 否;层=>
甜的!所以我应该能够通过根 UIView 的子视图递归循环,并改变我的内心内容。
问题是,当执行这个循环时,根 UIView 只显示一个子视图(ABPersonTableView),我不能再深入了。
任何想法为什么?ABPersonTableView 是隐藏它创建/包含的所有内容的私有类吗?
我可以通过在递归循环中执行此操作来更改表格的背景颜色:
if ([subview isKindOfClass:[UITableView class]]) { ((UITableView *)subview).backgroundColor = [UIColor PurpleColor]; }
但是,我无法访问任何 UILabel,因为我无法访问 ABPersonTableView 的任何子视图。
有任何想法吗?