It seems that currently ASTableNode and ASTableView both lack the support of section header/footer view.
I cannot only find a protocol method:
- (nullable NSString *)tableNode:(ASTableNode *)tableNode titleForHeaderInSection:(NSInteger)section
which shows nothing.
And the delegate/dataSource setter methods have been intercepted by AsyncDisplayKit, so that I cannot use the UIKit's way to do it.
So can I add section header/footer view when I'm using AsyncDisplayKit?
Just find out that ASTableNode will call the UITableViewDelegate methods.
So just implement the methods
- (nullable UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section;
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section;
And it will work just like before.
Related
We know that iOS 13 adds the ContextMenu function to UITableView, we can use the following method to display the context menu of UITableViewCell:
- (nullable UIContextMenuConfiguration *)tableView:(UITableView *)tableView contextMenuConfigurationForRowAtIndexPath:(NSIndexPath *)indexPath point:(CGPoint)point
But how can we show a menu for multiple selected rows? Like the "Files" app?
Starting with iOS 16, the UICollectionView added this:
- (nullable UIContextMenuConfiguration *)collectionView:(UICollectionView *)collectionView
contextMenuConfigurationForItemsAtIndexPaths:(NSArray<NSIndexPath *> *)indexPaths
point:(CGPoint)point
It's strange that UITableView doesn't have this function, did Apple forget to do it? :)
Is there a way to achieve the same for UITableView ? Or am I missing something?
Is there a way to achieve the same for UITableView?
I am running into a strange problem regarding Uitableview cells in Xcode 6 iOS8. When I create a tableViewController from storyboard and choose static cells, the view shows up as it suppose to. However, when I connect that same view to a TableViewController source, the cells disappear. I connected all necessary things (reusable cell_ID, etc). Anyone experience this? This used to work for me previously. Thanks in advance!
Make sure that you don't implement any of UITableViewDatasourceDelegate methods in your TableViewController such as these methods below.
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
}
I want to add search bar to UITableView header, it's visible on IB but not on emulator after running
Check that you are actually calling- initWithNibName: bundle: method properly.
Actually headers are the part of section in table view, so ur view controller class must conform to UITableViewDelegate protocol and must implements the method
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section;
and for customization of ur header view use
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
example
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
return 25.0f;
}
or you can use UITableViewDataSource method
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
return #"#";
}
I made a UITableViewController and tried loading it the previous view
[self.view addSubview: poll_ridingController.view];
but when i run it, it display me a blank kid of thing where the footer was supposed to be.
See the attached Picture.
The view you see IB just has what I like to call "eye-candy data" which means that Interface Builder does not implement any data into your project that is your job. The methods you will need to make sure you implement are:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
For more information read the Apple Documents
I have a project in which I need to put two UITableView on one UIView.
I know it needs to set <UITableViewDelegate,UITableViewDataSource> and can function below:
-(NSString *) tableView:(UITableView *) tableView
titleForHeaderInsection:(NSInteger)section
- (NSInteger) numberOfSectionsInTableView:(UITableView *)tableView
- (NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
-(NSIndexPath *)tableView:(UITableView *)tableView
willSelectRowAtIndexPath:(NSIndexPath *)indexPath
- (void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath
but I do not know if these can process two tableviews (different from 2 sections).
It looks like you're asking if one object (maybe a view controller?) can have two UITableViews both using it as their delegate. Yes, a view controller can be the delegate for multiple table views-- that's why all of those methods pass in a UITableView* as their first argument; it's for you to use to figure out which one is which. You should keep a couple instance variables (IBOutlets probably) in your view controller so you know which is which and you can act appropriately.
Cheers,
Interdev.