我使用nib文件构建用户界面,但现在我切换到storyboard,我发现了一个问题。
在nib文件中,我部署了10个按钮,并使用参与按钮- IBOutletCollection (UIButton *) NSArray第一个按钮的值为0,第二个按钮的值为2,依此类推(在OutletCollection Array中)。
但是使用UIStoryBoard的按钮是随机放置的。
有人知道如何解决这个问题吗?
感谢您的回答:)
发布于 2013-04-10 22:44:21
为了解决这个问题,我设置了添加到of集合中的UIViews的标签,然后将这个添加到viewDidLoad中……
NSComparator compareTags = ^(id a, id b) {
NSInteger aTag = [a tag];
NSInteger bTag = [b tag];
return aTag < bTag ? NSOrderedAscending
: aTag > bTag ? NSOrderedDescending
: NSOrderedSame;
};
self.UIViewCollection = [self.UIViewCollection sortedArrayUsingComparator:compareTags];现在我的UIViews的订单是1-20。outlet-collection只是一个对象数组。
https://stackoverflow.com/questions/12713293
复制相似问题