well my issue is:
I want to have table view but I want to keep first cell always first , and never let it scroll
but other cells should scroll.
can someone please suggest me how to do so ?
If your table have only one section than create custom view like cell and add this view in
table delegate method
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
like
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
return <Your View>
}
but it works if and only if one section in given in table.
The above answer with the static cell in the header works.
You might want to create another tableview just above the present one, with just static cells in it. Just below this table view, keep the present one with (number of all cells - number of static cells) without any offset. It looks as just one table view. This way, you can have more than one static cell with all the properties of a Tableview cell.
Related
I put the iCarousel View in a table View and try to scroll the iCarousel, but the problem is it's not scrollable at all.
I can see iCarousel in the cell like following:
and I put iCarousel datasource and delegate in the tableView Controller, create a customer function to set the iCarousel datasource and delegate.
In the CustomTableViewCell I just define the setting delegate function:
- (void) setICarouselDataSourceDelegate: (id<iCarouselDelegate,iCarouselDataSource>)dataSourceDelegate {
self.carousel.dataSource = dataSourceDelegate;
self.carousel.delegate = dataSourceDelegate;
[self.carousel reloadData];
}
and in the MainTableView, I call the DataSourceDelegate in the
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
First of all iCarousel is not any standarad View ... you should put link of the control that you're using
Second it seems like iCarousel is uses UIScrollView and UITableView is also derived from UIScrollView It's never a good idea to put a scrollview inside another scrollview.
This might be the reason why your table view is not scrolling.... BTW are you talking about horizontal scrollign or vertical scrolling ?
Currently I am using the iCarousel in Table View cell and it scrolls easily.
Just add standard view to cell in Storyboard.
In IB mark the class of that view to iCarousel.
Furthermore !ENABLE! user interaction on that view. (Maybe because of that you can't scroll the content inside the cell)
Implement separate datasource & delegate for every cell. (It is more clear which data are loading in the cell and also the cell itself can handle the data. You just pass the data to cell and it handles it accordingly.) - But it depends on you if you want to let one class to handle two separate control datasources & delegates :-)
I want to recognize when i select a cell and drag it over another cell.
Is there any example/ workaround for this?
My goal is to create an UITableView which allows me to merge two cells into one cell.
Thanks
You can use UITableView delegates
to move rows
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
And To compare CGRects
self.tableView rectForRowAtIndexPath:(NSIndexPath *)
Then, I believe, create, insert new cell.
I have a Storyboard which contains a UITableViewController. The table view is static and contains two sections. The table view was setup entirely in IB (including the header and footer text of the table view sections) - I have not implemented any table view delegate methods in my view controller.
If I attempt to get a reference to the UITableViewHeaderFooterView for a given section it always returns nil.
UITableViewHeaderFooterView* header =[self.tableView headerViewForSection:0];
When I run the app I can see the header and footer text that I set in IB so I know those views are there. I just can't figure out how to access them programmatically.
Any help would be much appreciated,
CS
Actually you'll need to specify the table footer view, and pass it to the table view using its delegate.
For example, suppose you have defined a IBOutlet UIView named tableFooterView.
Then in the following delegate method, you can pass your tableFooterView to your table view:
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section; // custom view for footer. will be adjusted to default or specified footer height
{
return self.tableFooterView;
}
Also you'll need to implement the following method to set the height of the table footer view:
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
return self.tableFooterView.frame.size.height;
}
I know it's the default property of rearrangement of tableviewcells when UITableView is in editing mode & user just reorder the Rows which is handled by UITableViewController.
As per Apple Doc : Reordering of Rows
Now what I want to do is, when I drag the cell over other cells, the backend cells should not get rearranged automatically, just the cell on which I drop the dragged cell should gets rearranged, a kind of Swapping between two cells.
For better understanding, please refer the below image. I should be able to Shift Jones to Room1 & the tableview controller should able to automatically be shifting Smith2 to Room3.
Below are delegates methods which I am using :
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
return YES;
}
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath {
NSString *temp = [roomstoringArray objectAtIndex:sourceIndexPath.row];
[roomstoringArray removeObjectAtIndex:sourceIndexPath.row];
[roomstoringArray insertObject:temp atIndex:destinationIndexPath.row];
// [temp release];
}
Problem is :
How can I stop other cells to get rearranged automatically while I
am dragging the cells over other.
There none of the delegate method which gets called when one used to
Drag the cell over others, only method called is
moveRowAtIndexPath when one drop the cell on it. So, even can't check for some condition & didn't find any scope of this enhancement
within existing TableView.
Is there any property with the TableView where I can stop such kind of behavior to perform the swapping between two cells only where rest of rows remain at the same indexPath.Alos, can someone please help me out with some-other way,if any.
For Problem you mention, Please check UITableView Delegates from here.
Below methods are helpful to you.
targetIndexPathForMoveFromRowAtIndexPath
canMoveRowAtIndexPath
For Swap b/w two rows you can get idea by this answer.
this is my grouped tableview:
Is it possible to avoid the spacing between sections and display the grouped table as if there is no sections?
Thanks in advance, yassa
Probably not what you want to hear, but no. No nice way to do this. I Think you are able to minimize the Space between the Groups but this will look very bad.
Another way would be to use one Section, but then you wont have this nice little Letters at the right side.
But if you want no Space between the Cells why dont you use UITableViewPlainStyle?
It appears that you don't have any content for header or footer in your table view, so I think you could achieve that by implementing table view's delegate methods :
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section;
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section;
Those two methods might work correctly if you also implement :
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section;
-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section;
returning nil for each.
In iOS 7 I customized space between sections in grouped table view by implementing next method:
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
return 10; // there might be your height
}
To make this method work prior to iOS 5, you should also return non-nil view in tableView:viewForFooterInSection:.
Prior to iOS 5.0, table views would automatically resize the heights
of footers to 0 for sections where tableView:viewForFooterInSection:
returned a nil view. In iOS 5.0 and later, you must return the actual
height for each section footer in this method.