I got a kind of problem. At this point I have made a custom tableviewcell, nothing fancy just two labels with 1px white shadow beneath the text. The problem is that when the user (me) select a cell the blue highlighting looks really awkward because of the shadow. So I need to disable/remove the shadow on highlighting.
I have not found any methods which are being called once the user selects the row, just after the user removes his finger.
So at this point I need to subclass UITableViewCell just to write two lines of code in the setSelected-method that does it. Are there any better ways to do this? And yes, I just add views to the contentView property of the cell.
And what is the layoutSubviews-method for? I don't find it in documentation but obviously it is in the iOS so...When does it get called and in what context?
Because when I subclass a UITableViewCell, what should I do with the sizes of the view-components?
Thanks in advance!
The below method is called just before the user is about to select the row....
- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath
Related
Is it possible to change how radius of the grouped UITableView? The rounded corners are way to drastic for my design.
I believe that the only way to do this is to provide your own background images for your table cells. You can provide 3 images to have a rounded feel to the UITableView like Apple Does.
in
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
set the cell's backgroundView to a UIView with the image you want based on the cell index. This will allow you to set the Top, Middle and Bottom.
This is a pretty good article
http://cocoawithlove.com/2009/04/easy-custom-uitableview-drawing.html
just be sure to dequeueReusableCellWithIdentifier:
No, it isn't. You can duplicate it though with a standard tableview and a couple custom background images.
You have to change both cell.backgroundView and cell.selectedBackgroundView with a view of your choice.
On the iPhone/iPad in the general settings they have a list of itms that display a '>' at the right hand side. When pressed it slides to another view.
Is this a control from the object palette? If so, which control? If not, what is the best way to achieve similar functionality.
I have looked at a lot of the samples on the Apple Dev site, but I cannot find a control like that, or at least I don't remember seeing it.
Any help on this foolish question is appreciated!! -:)
Thanks
Any time you see a view that is a scrollable list of items, you are looking at a UITableView, and each item in the list is defined using a UITableViewCell. To make the UITableViewCell show the '>', you simply have to set its 'accessoryType' to 'UITableViewCellAccessoryTypeDisclosureIndicator'.
This only draws the '>', it doesn't slide in the other view. However, when a user selects a UITableViewCell, it will call a function on its delegate:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;
In here, you will write the logic that slides in the new view controller (using UINavigationController's -pushViewController:animated:).
To learn more about how to use UITableView, I would highly suggest reading through the UITableView programming guide. It also links to downloadable projects with sample code.
You probably mean the combination of a UITableViewController and a UINavigationController. Create a new "navigation based app" to check out how it works & have fun. :)
Both are available in IB under the Controllers section.
The control you're looking for is a UITableview with disclosure indicators. To get the disclosure indicators (either the grey chevrons or the blue buttons), set editingAccessoryType for each tableview cell. That will give you a '>' on the right side of each item in your tableview.
When you tap on one of the '>'s, the tableview's delegate will have this method called:
- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
This is different from the method that is called if you tap anywhere else on the row:
- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
As dominostars said, you create another view and use UIViewController's pushViewController method to have another view slide in from the right.
Is there a way to add delete controls, like in UITableViewCell, on a table section? I see two ways:
Use table cell instead of sections.
Write own UIView section class, which will show delete controls.
Regarding the first way - as I think, it could be an easiest way in my situation.
The second way may be better from the implementation point of view, but it will take more time.
May be I missed another way? Any suggestions?
The only way I see is to provide your UITableViewController Delegate or Subclass with the method called:
- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
This gives you the power to display any kind of UIView as a section-header. within this view you can place controls that enable the user to delete sections.
I hope this helps a bit.
I'm trying to make a table view with an appearance much like the default Weather application provided by Apple. However I'm struggling a bit to make the table cells look correctly.
I would like all the cells, except the first one to be deletable. The problem is that the default cells have the small delete button on the left side of the cell instead of inside the cell. This causes the cells to shrink to the right, except the first one which keeps its size since it's not deletable.
So my question is if there is any way to tweak the default UITableViewCell to have the same behavior as the cell used in the Weather app? Or do I have to implement my own cell with button animation, etc, etc?
It turned out that somebody else had already answered this in a slightly different question:
- (BOOL)tableView:(UITableView *)tableView shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath
{
return NO;
}
it looks like that all apple is doing is making the background black for the delete button content area. i would try doing something like that first.
Is there any way to decrease the standard width of grouped UITableViewCell and put a custom button on the left side(outside of cell boundary)? I tried to change the cell size but it keeps same
You are going to have to fake the editing mode.
What I mean by that is that as AtomRiot said you have to subclass UITableViewCell so that when in editing mode you show the button you want on the left, outside the cell.
But first things first.
To change the indentation level for your cells all you need to do is implement this delegate method for the UITableView
- (NSInteger)tableView:(UITableView *)tableView indentationLevelForRowAtIndexPath:(NSIndexPath *)indexPath
So that takes care of it. Then in your UITableViewCell subclass all I would do is to implement the method
- (void)setEditing:(BOOL)editing animated:(BOOL)animated {
which I assume is called when the table the cell belongs to has changed to editing mode.
There I would fade in (or animate in any way you want) a button to appear on the left of your cell.
I have done it inside a grouped-style cell but never on the outside.
Give it a try!
You could subclass UITableCell and add your own custom views inside of it. I have not personally added a button inside one but it should work. It may get confused with the row selected call the tableview makes if you are implementing that.
The Cocoanetics blog seems to have a pretty good solution to this:
http://www.cocoanetics.com/2010/03/how-to-shrink-cells/