久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

UITableView 一次只勾選一行

UITableView Checkmark ONLY ONE Row at a Time(UITableView 一次只勾選一行)
本文介紹了UITableView 一次只勾選一行的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

使用此代碼,我可以檢查表中的多行.

With this code, I can check multiple rows in a table.

但我想要的是一次只檢查一行.這是我的代碼:

But what I want is to only have one row checked at a time. Here's my code:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    UITableViewCell *theCell = [tableView cellForRowAtIndexPath:indexPath];
    
    if (theCell.accessoryType == UITableViewCellAccessoryNone) {
        theCell.accessoryType = UITableViewCellAccessoryCheckmark;
    } else if (theCell.accessoryType == UITableViewCellAccessoryCheckmark) {
        theCell.accessoryType = UITableViewCellAccessoryNone;
    }
}

如果用戶選擇了不同的行,那么我希望舊行簡單地自動取消選中.不知道該怎么做.

If a user selects a different row, then I want the old row to simply automatically uncheck. Don't know how to do that.

推薦答案

最好的方法是在cellForRowAtIndexPath中設置附件類型.

The best way is to set the accessory type in cellForRowAtIndexPath.

使用didSelectRowAtIndexPath只記錄應該選擇哪條路徑,然后調用reloadData.

Use didSelectRowAtIndexPath to only record which path should be selected and then call reloadData.

這篇關于UITableView 一次只勾選一行的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Using Instruments to test an iOS app without having source code to the application(在沒有應用程序源代碼的情況下使用 Instruments 測試 iOS 應用程序)
KIF: How to auto-run/stress test an iOS app to find the cause of a rare UI bug?(KIF:如何自動運行/壓力測試 iOS 應用程序以找出罕見 UI 錯誤的原因?)
Can#39;t change target membership visibility in Xcode 4.5(無法更改 Xcode 4.5 中的目標成員身份可見性)
UITableView: Handle cell selection in a mixed cell table view static and dynamic cells(UITableView:在混合單元格表視圖靜態和動態單元格中處理單元格選擇)
How to remove Address Bar in Safari in iOS?(如何在 iOS 中刪除 Safari 中的地址欄?)
iOS 5 SDK is gone after upgrade to Xcode 4.5(升級到 Xcode 4.5 后,iOS 5 SDK 消失了)
主站蜘蛛池模板: 日韩一区二区免费视频 | 51ⅴ精品国产91久久久久久 | 在线观看视频中文字幕 | 日韩美女一区二区三区在线观看 | 在线精品亚洲欧美日韩国产 | 在线播放日韩 | 亚洲 欧美 精品 | 中文字幕成人免费视频 | 久久久久久中文字幕 | 成人免费在线观看 | 欧美日韩在线免费观看 | 国产精品成av人在线视午夜片 | 五月婷婷丁香婷婷 | 日韩免费av一区二区 | 国产91亚洲精品一区二区三区 | av手机在线看 | 中文字幕一区二区视频 | 国产精品一区二区久久精品爱微奶 | 国产精品久久久久久久久久久久冷 | 99pao成人国产永久免费视频 | 久热国产精品视频 | 欧洲精品在线观看 | 黄色av网站在线观看 | 色久五月| 欧美日韩中文字幕在线 | 毛色毛片免费看 | 国产精品久久久久久吹潮 | 日本视频一区二区三区 | 99久久精品免费 | 久久国内精品 | 亚洲三区在线 | 午夜国产一级 | 伊人狠狠 | 亚洲美女视频 | 色男人天堂av | 黄色av网站在线观看 | 久久精品二区亚洲w码 | 视频1区2区 | 国产美女精品 | 久久婷婷麻豆国产91天堂 | 日本超碰|