2012-10-03 20 views
1

我正在使用nib文件來構建用戶界面,但現在我切換到故事板並找到了一個問題。UIStoryboard - OutletCollection

在筆尖文件,我已經部署10個按鈕和我以前參加按鈕 - IBOutletCollection (UIButton *) NSArray 第一個按鈕具有0值,所述第二2,依此類推(在OutletCollection Array)。

但是使用UIStoryBoard按鈕隨機放置。

有誰知道如何解決這個問題?

謝謝你的答案:)

回答

0

我做了處理,這是我設置的是我加入到我的outletcollection加入這個我viewDidLoad中的UIViews的標籤是什麼?

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只是一個對象數組。

相關問題