2016-03-29 20 views
0

Sorunum hakkında yaklaşık 2 günlüğüne şımartıldım. Ama sorunumla eşleşen herhangi bir çözüm bulamadım. Benim sorunum, UITableView için aşağıdan bir resim gibi özel bir SectionIndexTitle yapmak istiyorum. Lütfen bana herhangi bir kütüphane veya bunu yapmak için konsept öner. Teşekkür ederim. enter image description hereUITableView SectionIndexTitle Özel Görünüm

cevap

0

Alfabetik bir dizin oluşturmaya çalışıyorsanız, bunu UITableViewDelegate içinde kutunun dışında destekleyen bir yöntem vardır.

Bölümlerinizi tanımlamanız ve sonra bunları dizine eklemek için UILocalized Indexed Collation kullanmanız gerekir.

let collation = UILocalizedIndexedCollation.currentCollation() 
    as UILocalizedIndexedCollation 

// table sections 
var sections: [Section] { 
    if self._sections != nil { 
     return self._sections! 
    } 

    // create objects from your datasource 
    var objects: [Object] = names.map { objectAttribute in 
     var object = Object(objectAttribute: objectAttribute) 
     object.section = self.collation.sectionForObject(object, collationStringSelector: objectAttribute) 
     return object 
    } 

    // create empty sections 
    var sections = [Section]() 
    for i in 0..<self.collation.sectionIndexTitles.count { 
     sections.append(Section()) 
    } 

override func sectionIndexTitlesForTableView(tableView: UITableView) 
    -> [AnyObject] { 
    return self.collation.sectionIndexTitles 
} 

override func tableView(tableView: UITableView, 
    sectionForSectionIndexTitle title: String, 
    atIndex index: Int) 
    -> Int { 
    return self.collation.sectionForSectionIndexTitleAtIndex(index) 
} 

okumak için daha yaklaşık UILocalized​Indexed​Collation