How i can create tableview like this?
(separators merges with edges and edges is rounded)
This was out of the box in system version below 7.0. If you want something similar, you can make custom graphic for the first and last cell. In UITableViewDataSource you have got a method, which helps you to control cell's content.
(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
From indexPath.row you can get cell number to know if it is first or last cell in the section. And you can set your custom cell look.
You can simply add UITextfields without background [UIColor clearColor] and put a background image to your login cell
If you would like to use table view with rounded corner you should go with QuartzCore framework by importing
#import <QuartzCore/QuartzCore.h>
then
in your method from where you create table view use following code -
yourTableView.layer.masksToBounds = TRUE;
yourTableView.layer.cornerRadius = 10.0f; // as per you requirement please give this value.
you can take any number of rows. but table corners remains as it is.
I think this will help you....
Related
I want to be able to move/shift the group of UITableViewCells in the UITableView downward, without scrolling the tableView, and without moving the entire tableview downward. The desired effect is that there is an amount of whitespace above the table view cells after they're placed in the table view, and when the user scrolls down through the table view, the white space is covered by the cells.
Don't forget that a UITableView is a subclass of UIScrollView.
And that UIScrollView have this property.
contentInset
The distance that the content view is inset from the enclosing scroll view.
#property(nonatomic) UIEdgeInsets contentInset
Discussion
Use this property to add to the scrolling area around the content. The unit of size is points. The default value is UIEdgeInsetsZero.
I don't fully understand what you are trying to do, so I just hope that this is what you are looking for.
After Question was Edited
Add an empty cell where you want it to be and adjust it's size when needed.
You will need to make some try about doing it animated (using insert and reloadCell) or using the reloadData option of the tableView to get the visual you want.
You could use a tableView header and adjust its size. After changing its size, call:
[tableView reloadData];
If you want to animate the size change, try calling:
[tableView beginUpdates];
[tableView endUpdates];
After changing the header's size.
EDIT 1:
As opposed to a table view header, you could use a static cell as mentioned in the other answer. To animate the size change, use the steps above. Change the size in:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
UPDATE: This is now fixed in iOS 8.0 and above. See my accepted answer for details.
I have an iOS 7 UITableView that I allow swipe-to-delete on rows. I'm handling deletions in:
tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
With:
[tableView deleteRowsAtIndexPaths:#[indexPath] withRowAnimation:UITableViewRowAnimationTop];
All rows are deleted with the correct animation, except for the last one in the table. When the user swipes to show the delete button, then taps it, the cell slides completely off screen to the left but leaves a white cell behind with the delete button still on it for a few tenths of a second before disappearing abruptly. It appears that this is happening with all the cells, but all other cells have a row below them that slides up, covering it up.
This even happens when the row in question is the only row in the table, where I delete the entire section instead of just the row. The section header slides up into oblivion but the white cell with the delete button sticks around for a little bit.
I would like this last cell to have the same UITableViewRowAnimationTop animation that the others do. Any ideas of what's going on?
UPDATE: This bug has been corrected in iOS 8. That final cell deletion now slides off to the left, the delete button slides up and away, and the background is clear (no more white area that abruptly disappears after the animations complete). The iOS 7 fix below is still needed when running below iOS 8.
iOS 7 Fix:
I was able to correct this problem by adding another section to the end of the table with a sufficiently tall section header view. This header view is styled to look like the blank area at the bottom of the table, so you can't see that it's there. When the last row of the table is deleted, this blank section header slides up and over it, hiding the delete button that's stuck there. This is a bit of a hack, but it looks like it's a table view bug.
As an alternative to the keep-an-empty-row trick mentioned by Frank Li, I've gotten around this ugly glitch by simply special-casing the deletion of the last row: Instead of animating the cell away, simply call -reloadData on the table view.
You won't get any animation, but you also won't see the glitch so your table view won't look broken. A worthwhile tradeoff.
my solution was to simply disable the broken animation by hiding the cell that's being deleted.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell* cell = [tableView cellForRowAtIndexPath:indexPath];
cell.hidden = YES;
}
I think a way-around is to always maintain an empty row below the last row in the table view. That will do the trick.
You can also use the UITableView.tableFooterView property:
- (void)viewDidLoad
{
[super viewDidLoad];
...
CGRect frame = [self.tableView rectForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0]];
UIView *view = [[UIView alloc] initWithFrame:frame];
view.backgroundColor = self.tableView.backgroundColor;
self.tableView.tableFooterView = view;
}
This code goes into the view controller holding the UITableView.
Code assumes ARC.
It's a different story if you use background image for the table.
The code can be surrounded by "if (iOS > 7)" clause.
What I want is for the buttons to look like this:
I just added my buttons from interface builder and connected them to the code. Does anyone know how to do this? And is it possible to do this with a UITextField object?
You'll want to use a UITableViewController with the sections set to be UITableViewStyleGrouped. Unless if you can find a background for each button, this is what the settings app uses.
To make a UITableView:
Each of the groups is a section, so you'll want to return how many sections you have with -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView.
For every section, you want to say how many rows there are with - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section.
You'll want to customize each cell with - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath (which, by the way, tells you which section's particular row you're modifying in the indexPath variable).
You'll want to handle the row click in - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath. The the code below helps you deselect the table view. :[self.navigationController pushViewController:detailViewController animated:YES];
also use - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender to handle what happens after tapping a specific row.
Tutorial that really explains this stuff in detail: http://www.appcoda.com/ios-programming-tutorial-create-a-simple-table-view-app/
Apple Documentation: http://developer.apple.com/library/ios/#documentation/uikit/reference/UITableView_Class/Reference/Reference.html
For the UITextField, you can set this to Grouped in the Interface Builder or pragrammagitaly to this: UITextBorderStyleRoundedRect
Good Luck!
If the standard UIButton is not sufficient, then create your own View:
You create an UIView class and in drawRect method you
draw a path consisting of 4 arc with 90° (corners) and connect that with CGPathLineTo.
Use corner radius, width and height as paramter.
Further tipps:
use CGTransformMakeScale such that you rectangle is transformed to a squre with side length 1. This simplifies the calculation of the arc parameter.
Dont forget to tranform the corner radius, too (e.g with scale.x)
Bit of background of the app I'm currently writing. It's a tableview and when a cell is tapped it loads a local HTML page.
However, now I'd like to implement section headers, a section header for complete and incomplete. The default header would be incomplete and after an interaction on the table view by a user, the cell is moved to complete. An option would be required to reverse the change should the change be done by mistake.
My first thought was to put in a check box in each cell, checking the box would move the cell and unchecking would move it back but I see iOS offers no such function, instead using switches instead.
For my needs, switches wouldn't work very well. So I'd like to ask others thoughts on this and how to implement such a thing, if anything.
Any thoughts or help appreciated.
Thanks.
You can implement a check mark using this approach. Basically you need to add a button on the cell and change its background image to show selected and deselected state. You can also consider using the default accessory check mark feature in tableview cell.
For eg:-
cell.accessoryType = UITableViewCellAccessoryCheckmark;
and
cell.accessoryType = UITableViewCellAccessoryNone;
In order to implement the section header, you can use - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section method or viewForHeaderInSection: method.
You can move a cell from one section to another one using the below method,
- (void)moveRowAtIndexPath:(NSIndexPath *)indexPath toIndexPath:(NSIndexPath *)newIndexPath
I Have one tableview(First) in that i want another tableview(Second) in the cell of first tableView.
In short i want each cell contains one more tableview.
So help me out with this problem.
Thanks in advance.
Although I think the below method is better this tutorial shows you how to create a tableView inside of another tableView http://iosstuff.wordpress.com/2011/06/29/adding-a-uitableview-inside-a-uitableviewcell/
My Solution:
That approach is bound to run into serious problems, so I suggest scrapping it. If you have nested table views (or scroll views, more generally) then the scrolling behavior of the views will be erratic. A better solution is to use variable height table view cells: you just create the cell view to hold all the multiple choice options you need, and implement
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
in your table view delegate to supply the heights of the cells.