I've got the problem that tableview methods are not called the first time the tableview is shown.
If I switch back to the previous view, and then click the button to show the tableview again, the methods are called this time.
I should say that I show an actionsheet while the tableview is loading.
The actionsheet I call in the ViewWillAppear method.
i fixed it by adding [self.tableView reloadData] after dismissing the actionsheet. i don't know if it's the proper way, but it somehow works.
Related
I have a viewController containing a UITableViewController. This UITableViewController is populated by an array. When User presses populated cells they segue with a segue set to 'Manuel Segue : Show' this creates a back button UINavigation bar item. Inside this viewController the user is able to add Items to the array populating the parent UITableViewController. The problem is that when i segue back using the UINavigationbarItem it does not call viewDidload on the UITableViewController, there by not updating the UIViewTableCells. I have to close application to make it call viewDidload... How do i make it call ViewDidload when returning from the Manuel segue show? All help appreciated.
The pushing view controller is not unloaded when another view controller is shown above. As viewDidLoad: is only called once in the view lifecycle, this would then not be called when the segue is unwound.
Updating your tableview in viewWillAppear: or viewDidAppear: would cause this to be called whenever this view is displayed.
viewWillAppear would perhaps be better if you don't want to show the user the table reloading when not needing to asynchronously load data.
Read more on iOS view controller lifecycle here:
https://developer.apple.com/library/ios/referencelibrary/GettingStarted/DevelopiOSAppsSwift/Lesson4.html#//apple_ref/doc/uid/TP40015214-CH6-SW3
I have a UITableViewController that allows for adding to it's cells through another TableviewController where the user can enter their data. I am passing the NSString data back to the first TableViewController properly as the NSLog states. However, the first TableViewController is not re-firing. I believe this is caused because I am using a modal transition. Would somebody explain to me how to make a UITableViewController re-fire with modal transitions?
in
-(void)viewWillAppear:(BOOL)animated
after adding to the table input array(datasource )
call
[tableView reloadData];
This is a follow up on a previous unsolved post.
I have a navcontroller, a tableview controller and a searchbar in the tableview. All this is built in storyboard.
I then build another viewcontroller programmatically when a cell is selected.
I do not want the navigation bar to appear in this last view so, in viewWillDisappear I call
[self.navigationController setNavigationBarHidden:YES animated:animated];
This works just fine IF I select a cell in the main tableView.
However, if the cell is selected after narrowing the data from a search in searchbar, then, the navigationbar will appear in the subsequent view although the call to setNavigationBarHidden is made in viewWillDisappear.
I tried repeating this call in viewDidDisappear and, now, the navigation bar disappears from the subsequent view although it is briefly displayed.
I would like to know what happens between the calls to viewWilldisappear and viewDiddisappear that apparently resets the NavigationBarHidden property?
This is what I found: The NavigationBarHidden property is apparently reset because when the searchbar leaves the view, it will send the navigationbar again on the view.
I am not sure I understand exactly what is happening, but this line of code in my viewWillDisappear solves the problem:
self.searchDisplayController.active=NO;
followed by:
[self.navigationController setNavigationBarHidden:YES animated:animated];
Of course, I would love to hear from someone who really understands what happens here.
I am using presentModalViewController to display a view which allows the user to modify data that is being displayed in the first view. After the user has updated the data, I would like to send [tableView reloadData] to the first view.
Is that possible? Or is there a method I can create in the first view that gets called when the modalView is dismissed.
It should fit perfectly for your needs
Method for when the modal view has been dismissed
EDIT: syntax errors :)
I have a cell with a few lines of text which changes colour when selected/highlighted. The problem is that as the new viewController is being pushed, the deselection animation occurs which is visually distracting as the text suddenly reverts to the unselected state. I have moved the deselectRowAtIndexPath statement after the line where the new view controller is pushed, but this has no effect.
How can I prevent the user seeing the cell deselection (without implementing a timer)? Any help would be appreciated please.
If you're using a UITableViewController, you won't need to call deselectRowAtIndexPath:. This will be done for you automatically when your table view becomes visible again.
If you're not using a UITableViewController because you have a more complicated interface, you would need to call deselectRowAtIndexPath: manually from the viewWillAppear:animated: method.
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.
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self.myTableView deselectRowAtIndexPath:[myTableView indexPathForSelectedRow] animated:YES];
}
so remove deselectRow from your didSelectRowAtIndexPath method.