0
我有一個相當複雜的UITableViewCell,並在生產代碼我能拉出一個選擇的UILabel與以下如何多個項目添加到一個UITableViewCell的內容查看
[[[[[[cell subviews] objectAtIndex:1] subviews] objectAtIndex:0] subviews] objectAtIndex:4];
一切正常沒問題 - 我遇到的問題是當我嘗試創建一個簡單的單元測試,以顯示預期如何工作。
出於某種原因,我不能夠建立具有在細胞中的內容查看屬性2項的情景
這樣我就可以輕鬆搞定[電池子視圖] objectAtIndex:0],但從來沒有1
在我的測試幫助我做下面來模擬這個(沒有運氣)
UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
UIView *view1 = [[UIView alloc] init];
UILabel *label1 = [[UILabel alloc] init];
UIView *view2 = [[UIView alloc] init];
UILabel *label2 = [[UILabel alloc] init];
[view1 addSubview:label1];
[cell.contentView addSubview:view1];
[view2 addSubview:label1];
[view2 addSubview:label2];
[cell.contentView addSubview:view2];
NSLog(@"inside ...%@", [[cell subviews] objectAtIndex:1]);