MonoTouch.Dialog Removing Lines at end of table - iphone

In the below screenshot I have a table but only a few elements. How do I tell MonoTouch.Dialog to not draw the extra lines at the bottom of the table when there aren't enough StyledStringElements to fill the screen?

I can think of two ways:
You set the UITableView.SeparatorStyle to UITableViewCellSeparatorStyle.None. However you will lose all separators (between all cells, not just at the bottom). OTOH That can be a good thing if you want to have your own custom separator.
You set an empty footer view to your UITableView, something like:
tv.TableFooterView = new UIView ();
You might want to select your own color (or clear) and not the default one.

It worked for me.(iOS Native)
self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
Not sure how to write it in MonoTouch.

Related

On scrolling tableView in subclass of UIView it appends white ugly marks in View?

I have made a custom combo files that is using in my project.Those files are here
UICombo.h and UICombo.m.
All is working fine except it add white mark over my super view on which it is added while scrolling.
I am not able to understand why it is happening.Any solution will be appreciated.
Using combo code here ...
UICombo *mwCombo;
mwCombo=[[UICombo alloc] initWithFrame:CGRectMake(10, 48, 177, 30) andItems:nil];
[mwCombo setAutoresizingMask:(UIViewAutoresizingFlexibleWidth| UIViewAutoresizingFlexibleRightMargin )];
[self.view addSubview:mwCombo];
My screen shots are give below.
Thanks!
set tableview z-position to -100 that is less than 0.And it is working as I have implemented in your example codes.Try adding following line before adding table view to self in init method in UICombo.m file.
[_tableView.layer setZPosition:-100];
I think you need to use the clipsoBounds property of your UICombo or on some of the views that it uses internally to draw itself. If you have structured this class nicely it will manage any other views that get created when it expands and on one of those views you should set clipsToBounds to YES, perhaps on the table-view itself.

add finishing separator on uitableview

I have a custom separator style (fairly simple):
[[UITableView appearance] setSeparatorColor:SOMECOLOR];
Now I want to have my tableview finish with a separator. Currently separators only appear between two cells, but I want to have a separator at the end.
see here:
any ideas how this could be done?
I usually make my own separator inside the table view cell. I do this with a UIView that spans the width of the cell and is 1 or 2 points high.
In your case, if you want the system separator, you would have to add a custom cell at the end which is all transparent and 1 point high. UITableView would then add the missing separator.
I understand it you want a separator at the end as well? You can add a footer view to achieve this effect.
Make a footer view with height of 0.0001. To do so simply implement the following tableview delegate method :
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
return 0.001;
}

iphone Custom table cell, UILabel needs to be scrollable

I have a custom table cell with a UILabel in. What I want can be done with two ways.
1- Find the height of the Label that contains long text and set the rowHeight to make the whole text visible.
2- Make the UILabel scrollable so the user can move the text up/down with his hand to read the whole string.
Can you please advice me on which one to do an how to do it?
If your text is static and won't change dynamically, you should use the first option. You can cache the result so whenever you refresh the table, you won't have to recalculate the text. You can use sizeWithFont:constrainedToSize:lineBreakMode to calculate the actual text size.
For the row height: you should use tableView:heightForRowAtIndexPath: and not rowHeight, since rowHeight will change the height for ALL rows - not only a single cell.
A far as a scrollable text view inside a table: in my opinion - it looks like a cheap solution in an app and makes it a bit amateur.
I recommend not using the first option in most cases as depending on the length of the string it could make your table cells huge.
As for the second option: You should be able to add a UIScrollView as a subview into the table view cells. The Scroll View can contain the fully sized text labels and let you scroll through them within a fixed size cell.
Do we have any example on how to do it? Im new to iphone, sorry for
bugging. – Panos 9 mins ago
UIScrollView *scroller = [[UIScrollView alloc]initWithFrame:cell.frame];
scroller.contentSize = CGSizeMake(280, 100);
UILabel *test = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 20)];
test.text = #"This would be your label.";
[scroller addSubview:test];
[cell addSubview:scroller];
This will make a UIScrollView and a label in the tablecell 'cell'. This will work, but I do not think this is the best solution, since it's gonna be a scrollview inside a tableview which already provides scrolling. My advice is to adjust the rowheigth.

UITableView - Lines Between Cells

I have a UITableView that has cells of which, for this example, let's say only the top two are filled. For the rest of the cells going down the list there are still separator lines.
Is there a way to turn the lines off where there are empty cells but keep them on to separate cells that contain information?
No there is no built in support for this.
You could turn off the cells on the table view with:
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
And then draw the separator lines in your own UITableViewCell subclasses that you use for the rows.
Another simple hack is to add this to the UITableViewControllers viewDidLoad Method:
self.tableView.tableFooterView = [UIView new];
One more way is do just write the line in viewdidLoad
self.myTableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];

Best (Any) way blend tableview section header onto top of a grouped tableview

I'd like to add section headers to my grouped table view's sections but I'd like them to appear seamless (see image). The default, as we're all well aware of, is rounded top corners on the first row of a grouped table view cell so it ends up looking like crap when you merge them.
Any way to specify when indexPath.row = 0 that the UITableViewCell should use row style "middle" or something like that?
If not then what are my options? I guess I could scratch the section header and use Row 0 as a quasi-header then push my array data +1 to fill the rest of the table? I'd rather not roll my own from scratch...if possible.
Sample Table http://img35.imageshack.us/img35/8181/sampletable.png
Edit:
"Crap" looks like this:
alt text http://img25.imageshack.us/img25/9748/crapsection.png
Don't do what you're doing, it's against HIG
Ok, ok, I'll tell you how to do it:
You're going to want to do your own cell background views. The default grouped one is not what you want.
When a tableview asks you for a cell, set its backgroundView and selectedBackgroundView to something that looks appropriate for its place in the tableview.
Usually, this means a UIImageView with the appropriate image, though you can go wild here with a custom view, but there are gotchas.
So in your case, you would do
if (indexPath.row > sectionRowCount - 1) {
//Not the last row
//Put in the middle background
} else {
//Put in the end background
}
Then you'll want a custom table section header, but that's pretty easy.
In your case, you probably won't have to worry about when there's just one row, so that makes things even easier.
Take a look at the tutorial here:
cocoa with love basically what you need is 3 different images. One for the top row, one for the bottom, and a 3rd for the middle rows.
You could also not use the section header, but instead use a custom cell as the first cell of the section. So when ([indexPath row] == 0), return a custom cell that is the "header" and then return the "regular" cells (offset by one row) for the rest. You'll also have to make adjustments to the numberOfRowsInSection function to return +1.