tableView reloadData and deselectRowAtIndexPath

tableView reloadData and deselectRowAtIndexPath

By : user2954821
Date : November 22 2020, 10:33 AM
it fixes the issue After several attempts, I've found something that works. You need to set the deselection to occur after a "delay" (of 0 seconds) in order to make sure it happens on the next draw cycle and gets animated properly.
code :
- (void)viewWillAppear:(BOOL)animated
    [super viewWillAppear:animated];

    NSIndexPath *indexPath = self.tableView.indexPathForSelectedRow;
    [self.tableView reloadData];
    [self.tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionNone];

    [self performSelector:@selector(deselectRow) withObject:nil afterDelay:0];


- (void)deselectRow
    [self.tableView deselectRowAtIndexPath:self.tableView.indexPathForSelectedRow animated:YES];

Share : facebook icon twitter icon
Issue with deselectRowAtIndexPath in tableView

Issue with deselectRowAtIndexPath in tableView

By : Cyril BAZIN
Date : March 29 2020, 07:55 AM
around this issue I think the general paradigm used with table views and pushing new VCs is that you deselect the table row in your viewWillAppear:animated method. Then as the VC is popped, they see which row had been used to navigate to that VC.
code :
- (void)viewWillAppear:(BOOL)animated
    [super viewWillAppear:animated];

    [self.myTableView deselectRowAtIndexPath:[myTableView indexPathForSelectedRow] animated:YES];

Why can't I call reloadData AND deselectRowAtIndexPath in viewWillAppear:animated at the same time?

Why can't I call reloadData AND deselectRowAtIndexPath in viewWillAppear:animated at the same time?

By : user3223426
Date : March 29 2020, 07:55 AM
Hope this helps When you reload a cell, it automatically gets deselected. That's because you don't set a cell's selected property to YES in tableView:cellForRowAtIndexPath:. So you will have to deal with this differently. Either identify that the cell at indexPath needs to be selected and appropriately set its selected property to YES in tableView:cellForRowAtIndexPath: or select it after you reload the data. In such case, you can execute the following methods –
code :
[self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]

[self.tableView selectRowAtIndexPath:indexPath 

[self.tableView deselectRowAtIndexPath:indexPath animated:YES];
tableview reloadData doesnt work - TableView Data are not correctly sorted

tableview reloadData doesnt work - TableView Data are not correctly sorted

By : Oskar
Date : March 29 2020, 07:55 AM
help you fix your problem Data stored in the database is not sorted by default. It is your responsibility to sort it. Depending on your data structure you can either add an index to aid in sorting or you can sort by some logical value such as name, lastSeenDate, etc.
Post the code that is retrieving the data from Core Data (probably the creation of your NSFetchedResultsController).
TableView will not update after adding new row to array [[self tableView] reloadData] doesn't work

TableView will not update after adding new row to array [[self tableView] reloadData] doesn't work

By : Miche
Date : March 29 2020, 07:55 AM
I hope this helps you . I've working on a program and I'm having issues getting a tableView to update. Pretty much I have an tableView and there is nothing but empty rows at first. Then the user hits the + sign and I PUSH a new tableview on top of the stack and the user can select from a master list of which rows they want to add to the initial table. The rows that the user picks are added to an array. When the user clicks the back button, the first table doesn't update. However, if I press the HOME key and then reload the app, the first table view displays the updated array. I have included the code from both tables and my gloabl array. , changed table 1.h to the following:
code :
@class baseTableViewViewController; @class BaseInfoDataController;

@interface baseTableViewViewController : UITableViewController <UITableViewDelegate, UITableViewDataSource>

@property (nonatomic, retain) UITableView *tableView;

Generic function does not update the value of label in tableview cell after tableView.reloadData()

Generic function does not update the value of label in tableview cell after tableView.reloadData()

By : Md Shakib Hassan
Date : March 29 2020, 07:55 AM
like below fixes the issue I have a function where I am incrementing the value of the label as below , you should change your code to this.
code :
let numLikes = Int(feeds[Int((indexPath.row))].likes)!
feeds[Int((indexPath.row)).likes = String(numLikes)
buttonClicked(data: feeds[Int((indexPath.row))].likes, tableView: userProfileTableView)

func buttonClicked(data:String,tableView:UITableView) {
    let data = String(Int(data)!+1)
    print("Incremented data", data)
Related Posts Related Posts :
  • Add an alertcontroller in a global swift file?
  • Take square image with Cordova (Phonegap) Camera API?
  • Amazon S3 policy allowing only upload not overwrite
  • How to change the UILabel content by tapping?
  • Adding checkmark to selected table cell also checks another table cell
  • UICollectionView cellForItemAtIndexPath indexPath row is nil
  • Resize and set quality on JPEG image while retaining EXIF in iOS
  • How to push rootviewcontroller in Ios
  • How to add UIBarbuttonItem at centre on UInavigationbar in iOS
  • Would this IOS device test crash be expected
  • PickerView not showing any values
  • How to set root view controller in storyboard animated with navigation controller programmatically
  • Can anyone suggest me the effective way to deal with s3 upload fail because of timezone difference issue?
  • Getting list of files in documents folder
  • Error while using Realm Object as a singleton. Is it a good idea?
  • inserting into SQLite database
  • More nodes than I should
  • Facebook IOS SDK navigate to another controller after login not working
  • Swift Array - use "Contains" of type AnyObject
  • Sidebar menu with indicate navigationbar on iOS
  • Programmatically set size of UIView from Storyboard
  • Navigation bar blink
  • Web services issue on POST method
  • Parse.com error 'Method not allowed when Pinning is enabled.' when I use a PFQueryTableViewController subclass
  • Swift can't send URLRequest at all?
  • No Provisiong profiles with a valid signing identity were found and Failed to locate or generate matching signing assets
  • iOS: how to set httponly flag for NSHTTPCookie
  • How to get the mac address of a beacon in objective-c without knowing its UUID, major and minor values?
  • tableView is not showing data from JSON in swift
  • iTunes reject app for date of birth
  • SWIFT reporting "Extra argument in call" - works in Playground
  • save data depending on passed value in swift
  • webview not showing on full Screen of iphone 6
  • Location Notification's based on Latest iOS Feature
  • Adjusting Height of UITableViewCell
  • How to show five digit unicode in iphone
  • unwind doesn't work
  • Confusion about coordinates, frames & child nodes in SpriteKit on iOS?
  • If Statements not being recognized by Xcode
  • readonly property in RubyMotion
  • 'No available types for source 1' when the app runs on my device(IPhone 6) swift
  • IOS:Remove view when clicked in background
  • Removing "\" from URL in iOS Swift
  • iOS - Send an email automatically (NOT from user's account)
  • The usage of NSNotificationCenter in the relationship of parent and children
  • When do Apple auto-renewable subscriptions renew?
  • Unknown large spacing between x-axis label and base of plot in core-plot
  • How do I change the displayed time format after NSTimer is initiated?
  • Swift JSON breaks when [ ] are used
  • Secure Memory For Swift Objects
  • didSelectItemAtIndexPath doesn't work normally
  • Swift Documentation Comments
  • Is there a simple way to assign a value only once(first time) inside a loop/repeatedly running method?
  • Play sound in while app in background
  • If I have an embedded unrestricted webview, does that mean I have third-party content?
  • UITapGestureRecognizer on UIScrollView
  • App does not respond to hardware volume changes on iPad
  • troubleshoot asp.net web app on iOS
  • What size should my tab bar item icons be?
  • Parse.com Facebook authorize never calls completion handler
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org