ALL BUSINESS
COMIDA
DIRECTORIES
EDUCATIONAL
ENTERTAINMENT
FASHION TIPS
FINER THINGS
FREE CREATOR TOOLS
HEALTH
MARKETPLACE
MEMBER's ONLY
MONEY MATTER$
MOTIVATIONAL
NEWS & WEATHER
TECHNOLOGIA
TELEVISION NETWORKS
USA VOTES 2024
VIDEOS
INVESTOR RELATIONS
IN DEVELOPMENT
Posted by - Latinos MediaSyndication -
on - December 26, 2023 -
Filed in - Technology -
-
358 Views - 0 Comments - 0 Likes - 0 Reviews
Tableview cells are visible while app is in debug but when tried to terminate app and than try to reopen the app, cells are not visible.
Approach(Which i used in my app):
lazy var contactPickerScene: ContactTabelViewController = { guard let contactPickerScene = self.storyboard?.instantiateViewController(identifier: "ContactTabelViewController") as? ContactTabelViewController else { return ContactTabelViewController() } return contactPickerScene }() contactPickerScene.contactDelegate = self contactPickerScene.multiSelectEnabled = true contactPickerScene.subtitleCellValue = .email contactPickerScene.view.frame = self.contactListView.bounds self.addChild(contactPickerScene) self.contactListView.addSubview(contactPickerScene.view) contactPickerScene.didMove(toParent: self)
public class ContactTabelViewController: UITableViewController, UISearchResultsUpdating, UISearchBarDelegate { --------------------------- public override func viewDidLoad() { super.viewDidLoad() // Uncomment the following line to preserve selection between presentations // self.clearsSelectionOnViewWillAppear = false // Uncomment the following line to display an Edit button in the navigation bar for this view controller. // self.navigationItem.rightBarButtonItem = self.editButtonItem self.title = "Contacts" self.tableView.dataSource = self self.tableView.delegate = self inititlizeBarButtons() initializeSearchBar() registerContactCell() fetchContacts() } --------------------------- }
// MARK: - Contact Operations extension ContactTabelViewController { func fetchContacts() { DispatchQueue.global().async { self.getContacts( {(contacts, error) in if (error == nil) { DispatchQueue.main.async(execute: { // self.tableView.dataSource = self // self.tableView.delegate = self self.contactsList = contacts self.tableView.reloadData() }) } }) } } func getContacts(_ completion: @escaping ContactsHandler) { if contactsStore == nil { contactsStore = CNContactStore() } let error = NSError(domain: "ContactPickerErrorDomain", code: 1, userInfo: [NSLocalizedDescriptionKey: "No Contacts Access"]) switch CNContactStore.authorizationStatus(for: CNEntityType.contacts) { case CNAuthorizationStatus.denied, CNAuthorizationStatus.restricted: DispatchQueue.main.async { if self.contactsList.isEmpty { self.tableView.isScrollEnabled = false self.resultSearchController.searchBar.isHidden = true self.tableView.setEmptyMessage("We could not fetch your contacts. Please allow contacts permission.") } } case CNAuthorizationStatus.notDetermined: contactsStore?.requestAccess(for: CNEntityType.contacts, completionHandler: { (granted, error) -> Void in if (!granted ){ DispatchQueue.main.async(execute: { () -> Void in completion([], error! as NSError?) }) } else{ DispatchQueue.global().async { self.orderedContacts = [String: [CNContact]]() self.getContacts(completion) } } }) case CNAuthorizationStatus.authorized: var contactsArray = [CNContact]() let contactFetchRequest = CNContactFetchRequest(keysToFetch:[CNContactVCardSerialization.descriptorForRequiredKeys()]) contactFetchRequest.sortOrder = CNContactSortOrder.givenName do { try contactsStore?.enumerateContacts(with: contactFetchRequest, usingBlock: { (contact, stop) -> Void in var key: String = "#" if let firstLetter = contact.givenName[0..<1] , firstLetter.containsAlphabets() { key = firstLetter.uppercased() } var contacts = [CNContact]() if let segregatedContact = self.orderedContacts[key] { contacts = segregatedContact } if(contactsArray.count == 0){ if !Constant.boolIsSubscribe { contacts.append(contact) } } contacts.append(contact) self.orderedContacts[key] = contacts contactsArray.append(contact) }) self.sortedContactKeys = Array(self.orderedContacts.keys).sorted(by: <) if self.sortedContactKeys.first == "#" { self.sortedContactKeys.removeFirst() self.sortedContactKeys.append("#") } completion(contactsArray, nil) } //Catching exception as enumerateContactsWithFetchRequest can throw errors catch let error as NSError { print(error.localizedDescription) } @unknown default: break } } }
While Debug:
After App Killed:
i want to result same as i got in debug. cell needs to load load while app running after kill from debug state.
in this issue i already spent 2 days and also create separate UItableviewcontroller but getting same result.
XCode Version 15.0 Swift 5.0 iOS 17.0 MacOS Sonoma
i am using this environment currently.
Same issue again in different scenario
i found same issue again in UITableView in same project and history page showing me some history while device attach to system and app is running but whenever i kill app and run it's showing blank tableview.
Logs while connected to device and run
12:57:19: 168 ==> GetLoadFileFromDocumentDict() 12:57:19: 197 ==> numberOfSections(in:) 12:57:19: 206 ==> tableView(_:numberOfRowsInSection:) 12:57:19: 197 ==> numberOfSections(in:) 12:57:19: 206 ==> tableView(_:numberOfRowsInSection:) 12:57:19: 220 ==> tableView(_:heightForRowAt:) 12:57:19: 220 ==> tableView(_:heightForRowAt:) 12:57:19: 220 ==> tableView(_:heightForRowAt:) 12:57:19: 220 ==> tableView(_:heightForRowAt:) 12:57:19: 220 ==> tableView(_:heightForRowAt:) 12:57:19: 197 ==> numberOfSections(in:) 12:57:19: 206 ==> tableView(_:numberOfRowsInSection:) 12:57:19: 238 ==> tableView(_:cellForRowAt:) 12:57:19: 220 ==> tableView(_:heightForRowAt:) 12:57:19: 220 ==> tableView(_:heightForRowAt:) 12:57:19: 220 ==> tableView(_:heightForRowAt:) 12:57:19: 238 ==> tableView(_:cellForRowAt:) 12:57:19: 220 ==> tableView(_:heightForRowAt:) 12:57:19: 238 ==> tableView(_:cellForRowAt:) 12:57:19: 220 ==> tableView(_:heightForRowAt:) 12:57:19: 238 ==> tableView(_:cellForRowAt:) 12:57:19: 220 ==> tableView(_:heightForRowAt:) 12:57:19: 238 ==> tableView(_:cellForRowAt:) 12:57:19: 220 ==> tableView(_:heightForRowAt:) 12:57:19: 220 ==> tableView(_:heightForRowAt:) 12:57:19: 220 ==> tableView(_:heightForRowAt:) 12:57:19: 220 ==> tableView(_:heightForRowAt:) 12:57:19: 220 ==> tableView(_:heightForRowAt:) 12:57:19: 220 ==> tableView(_:heightForRowAt:)
Logs while not connected to device and run
13:11:59: 168 ==> GetLoadFileFromDocumentDict() 13:11:59: 197 ==> numberOfSections(in:) 13:11:59: 206 ==> tableView(_:numberOfRowsInSection:) 13:11:59: 197 ==> numberOfSections(in:) 13:11:59: 206 ==> tableView(_:numberOfRowsInSection:) 13:11:59: 220 ==> tableView(_:heightForRowAt:) 13:11:59: 220 ==> tableView(_:heightForRowAt:) 13:11:59: 220 ==> tableView(_:heightForRowAt:) 13:11:59: 220 ==> tableView(_:heightForRowAt:) 13:11:59: 220 ==> tableView(_:heightForRowAt:) 13:11:59: 197 ==> numberOfSections(in:) 13:11:59: 206 ==> tableView(_:numberOfRowsInSection:) 13:11:59: 220 ==> tableView(_:heightForRowAt:) 13:11:59: 220 ==> tableView(_:heightForRowAt:) 13:11:59: 220 ==> tableView(_:heightForRowAt:) 13:11:59: 220 ==> tableView(_:heightForRowAt:) 13:11:59: 220 ==> tableView(_:heightForRowAt:)
i don't know why cellForRowAt is not getting called.