آموزش های این وب سایت به صورت رایگان در دسترس است. اطلاعات بیشتر
بروز خطا
   [message]
اشتراک در سوال
رای ها
[dataList]

هایلایت کردن جستجو در TableView

127457  8 سال پیش  8 سال پیش
0 0

با سلام من به وسیله دیتابیس sqlite یه دیکشنری ساختم میخوام زمانی که  کلمه ای جستجو میشه در لیست به صورت رنگی هایلایت شده نمایش داده بشود میخواستم بدونم از چه کدی و کجا استفاده بکنم کدم به صورت زیر می باشد

class ViewController: UIViewController , UITableViewDataSource, UITableViewDelegate {

var word:String!


@IBOutlet weak var tabelView: UITableView!
@IBOutlet weak var text1: UILabel!
internal let db = DB.getInstance()
override func viewDidLoad() {
super.viewDidLoad()


}
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}

func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return AppDelegate.contacts.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("customCell", forIndexPath: indexPath) as!
CustomTableViewCell

let contact = AppDelegate.contacts[indexPath.row]
cell.index = indexPath.row
cell.labelfullname.text = contact.firstname!


return cell
}

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath){


let vcEditContact = storyboard?.instantiateViewControllerWithIdentifier("ViewControllerEditContact") as! ViewControllerEditContact
let contact = AppDelegate.contacts[indexPath.row]
vcEditContact.firstname = contact.firstname
vcEditContact.lastname = contact.lastname
vcEditContact.indext = indexPath.row


navigationController?.pushViewController(vcEditContact, animated: true)

}


@IBAction func textedit(sender: UITextField) {


word = sender.text
if word != "" {
AppDelegate.contacts.removeAll()
let records = db.executeQuery("select * from mn where wd like '\(word!)%' ")


if records.count > 0 {


for record in records {

let structContact = StructContact()

structContact.firstname = record.column["wd"]?.asString()
structContact.lastname = record.column["matn"]?.asString()
AppDelegate.contacts.append(structContact)

self.tabelView.reloadData()

}

}

}


}



override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)


self.tabelView.reloadData()


}


}

 

 برای این سوال 1 پاسخ وجود دارد.
پاسخ به سوال 
127457  8 سال پیش
0 0

با سلام استاد کاشی زاده لطفا یه راهنمایی بکنید


پاسخگویی و مشاهده پاسخ های این سوال تنها برای اعضای ویژه سایت امکان پذیر است .
چنانچه تمایل دارید به همه بخش ها دسترسی داشته باشید میتوانید از این بخش لایسنس این آموزش را خریداری نمایید .