I have a table view along with search bar.
I want to ensure that while scrolling the tableview, the searchbar stays on top - always.
How can this be achieved?
I suggest you to Keep both of them separated.
You have to return your search bar in the table's delegate callback
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
Note: don't forget to implement tableView:heightForHeaderInSection:
Related
I wonder which view is used in the next image?
UITableView or UIWebView?
I always wondered how one can tell if a view is embedded inside a web view or not.
Anyway, anyone knows the answer for this specific view?
You can set individual height to individual UITableViewCell using this delegate Method
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
I'd like to implement a grouped and indexed UITableView without section headers.
I'm using sectionIndexTitlesForTableView:(UITableView *)tableView to return my titles.
I also implemented tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section and returned nil as well as tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section and returned 0.0f.
Both doesn't remove the section headers. There is still a space between the different sections.
I had the same problem and could not find a solution. In the end, I had to subclass UIViewController (not UITableViewController) and use a UITableView with transparent background and the style set to UITableViewStylePlain. Then, I created custom cells for the first and the last row (with rounded corners) and some transparent margin left and right. I can give you more details if you want, but as it does not answer your question straight, I'll just share this link for now.
I need some clever hints here :)
I need to add a tool bar to my page containing a table view. If the table does not fill up the entire page I need the tool bar to be positioned at the bottom at the page but if the table is longer than the page I need the tool bar to be positioned at the end of the table.
What to do?! :/
Thanks a lot for any help,
Stine
Use the footer view of UITableViewDelegate....
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
Simply return a view from this and it will be placed at the bottom of the specified section (either a single section or your last one).
Also use..
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
To tell the Table view the height of the view.
In some apps such as Cool Iris, LiveShare, i see them using custom views for their plain UITableView section titles. Is there a way to replace the standard section title bar with a custom view?
In order to customize the look of your section header, there are two methods you will probably want to use.
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
and
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
These are both found in the UITableView delegate protocol. The first will let you create a custom view to display as your section header. The second just makes sure you get the size you want for it so that your view doesn't get cut off
I have a table view with multiple sections. I want to display different section header titles and want to add a label on the right corner of each section at a right margin of 4px.
Can I implement both
- (NSString *)tableView:(UITableView *)iTableView titleForHeaderInSection:(NSInteger)iSection
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
to achieve this?
Only one of them will ever get called successfully. tableView:viewForHeaderInSection: will get precedence.
Define a view with a title label and another label that sits on the right corner and return it in tableView:viewForHeaderInSection: with the values set.