I have two cells in my tableview, each with a text field. Following these two cells are many addition lines even though there are no cells to follow. How do I remove these lines to create a cleaner look.
Side Note:
The reason I didn't use static cells created through the storyboard is because the situation requires to create the cells through code.
And this is for Objective-C
tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
Swift 3
tableView.tableFooterView = UIView(frame: .zero)
To remove the extra shown empty cells just set tableFooterView to an empty view
tableView.tableFooterView = UIView()
Related
I tried both changing the separator style to None in IB and .none in code. In other tables that have a simple label in the row in other parts of my app, when I try to remove the separator style it works. But for some reason, in this UITableView it does not and I'm not sure why. Here is the screenshot from the simulator.
And here is a screenshot of the storyboard
In the storyboard, it's basically a UIView on the left with the initials, and then the three labels are embedded in two UIStackViews. There's a bottom horizontal UIStackView for grade and school, and then a vertical UIStackView for name and the bottom stack view. Do stack views prevent you from using separator style = none?
Try this :
self.tableView.separatorColor = [UIColor clearColor];
OR
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
I have attached an image of cells in a table view, and you can notice the 2 separator lines in the middle are a tiny bit thicker/darker than the 2 outer lines. I want the lines to all be consistent, and the color/thickness of the outer two lines. I could not find a solution, so I am wondering if anyone knows of any. I figure it would be a simple solution, but I haven't been able to figure it out. Thanks guys.
Select your UITableView from xib or storyboard, then make the UITableView separator to None.
See the image
Then place a UILabel with the width same as of UITableViewCell and height=1 in the bottom of your cell, clear the text of the label and set the backGround color as per your wish, this will solve your problem.
Hope this helps you.
Create a custom separator Line Programatically:
UIView *separatorLine = [[UIView alloc] initWithFrame:
CGRectMake(0, cell.contentView.frame.size.height - 1.0,
cell.contentView.frame.size.width, 1)];
separatorLine.backgroundColor = [UIColor blackColor];;
[cell.contentView addSubview: separatorLine];
or you can add a image view for separator in custom UITableviewCell in UI
I would like to implement segmented controls like this (circled with red) :
(When we scroll this view, the segmented controls stay sticky at the top of the view, that makes me think it's a cell on its own ? but I may be wrong).
I have already implemented a custom cell (that displays kind of what is above the red ellipse in the above picture, in purple) and add it to the header of my table view like so :
BigCell *cell = [self.tableView dequeueReusableCellWithIdentifier:#"BigCell"];
self.tableView.tableHeaderView = cell;
Now, I think I should create a second cell with the segmented controls in it and add it also to the table header (and not in the section header, because I have many sections with their titles).
Then, I would create a UIView containing this two cells and add this view as the header of my tableView ? Is this a correct way to do it ?
Thank you very much for the help !
I think you have a couple of options.
1) Make a container view to host both of your "cells" (which needn't be UITableViewCells - just views...). Add the singular container view as the table header.
2) Forego using the table header altogether and just place your views above the table, making it shorter. This is more complicated if you're using a UITableViewController, but simple if you're just hosting a UITableView in some other custom UIViewController.
this is an example with uilabel that stick to the top - just change it to your uisegmentedcontrol
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView *viewForSectionHeader = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, SETTINGS_HEADER_HEIGHT)];
[viewForSectionHeader setBackgroundColor:[Utils colorHeaderBlue]];
UILabel *lblSectionTitle = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, self.tableView.frame.size.width, SETTINGS_HEADER_HEIGHT)];
lblSectionTitle.text = #"PROFILE";
lblSectionTitle.textAlignment = NSTextAlignmentCenter;
lblSectionTitle.textColor = [UIColor whiteColor];
[viewForSectionHeader addSubview:lblSectionTitle];
return viewForSectionHeader;
}
I use a dynamic tableViewController. I implement the numberOfSection to return 4, and the numberOfRowInSection return 1. These are the only changes I made for the blank TableViewController. But when I run it on simulator, it shows multiple cells, which I expected to be only four cells. Why is that?
Note: If I change the height of each cell to let the screen only fit four cells at a time, it will work fine since it won't let be me scroll down. So I guess is the tableViewController always try to fill the screen no matter how many cell it should display?
Yes, the UITableView will always continue to fill the screen with 'empty' cells of the default row height. To prevent this, you could add the following code in viewDidLoad:
self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
(For Swift, check #VictorSigler's answer.)
In Swift:
self.tableView.tableFooterView = UIView(frame: CGRect.zeroRect)
My first problem that i had was that my last UITableViewCell never had a separator which i wanted. I solved it using this code:
self.tableView.tableFooterView = [[UIView alloc] init];
Now that worked perfectly however with one problem. when i add that all my other views disappear. Here is a picture of before i use the one line of code above and after:
How can i fix this?
Set a zero height table footer view, like so:
self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
Because the table thinks there is a footer to show, it doesn't display any cells beyond those you explicitly asked for.
Have you tried to use the viewForFooterInSection function?
Add a vertical spacing of 0 between your table view bottom and the view's top which is placed below it. And you need to set one view's height fixed either for UITableView or UIView. Add this code of line in viewDidLoad. It will display the separator also for last cell.
self.tableView.tableFooterView = [UIView new];
Screenshot:
May be this help
You have to set translucent property of tab bar controller
see this question to more reference...
iOS 7 TabBar Translucent issue