第一次使用OutletCollection,有些问题不太清楚。有多个分段空间,需要确定全部都被选中才能进行下一步。我只会检测单独的选项:
int selectedSegment = segment.selectedSegmentIndex;
if (selectedSegment == -1 )
{
//do stuff/alert
}
但是怎么批量检测?我已经设置了IBOutletCollection:
IBOutletCollection(UISegmentedControl) NSArray *allSegmentControlOutlet;
不知道如何遍历全部选项。
这样遍历:
for (UISegmentedControl *control in allSegmentControlOutlet) {
////....
}
IBOutletCollection 的用法可参见:Interface Builder Outlet Collections
for (UISegmentedControl *control in allSegmentControlOutlet)
{
if (control.selectedSegmentIndex == -1 )
{
//do stuff/alert
}
}