我有一个 Stack 来填充一组视图。
_countViewArray = [[NSArray alloc] init];
_countViewArray = @[self.a.view,self.b.view,self.c.view];
_stackView = [NSStackView stackViewWithViews:_countViewArray];
它运作良好。如果我想用可变数组替换这个数组怎么办?
我为“动态”堆栈视图尝试了此代码,最后将可变数组转换为简单数组,但不起作用:
_mutableCountViewArray = [[NSMutableArray alloc] init];
[_mutableCountViewArray addObject:@[self.a.view]];
if (caseCondition){
[_mutableCountViewArray addObject:@[self.b.view]];
}
[_mutableCountViewArray addObject:@[self.c.view]];
_countViewArray = [_mutableCountViewArray copy];
_stackView = [NSStackView stackViewWithViews:_countViewArray];
在控制台中,如果我打印可变数组,我有:
(
(
"<NSView: 0x600000121ea0>"
),
(
"<NSView: 0x600000120780>"
,
(
"<NSView: 0x6000001235a0>"
)
)
我该如何解决?