How to make a row in UITableView invisible? - objective-c

I'm very new to this field...I'm using a UITableView to create a table in my apps..but based on some certain checks, I need to make some of the rows invisible...how can I achieve that??

To accomplish this, you simply have to change the UITableViewCell itself. But I don't really know, whether this abides by Apple's HIG (Human Interface Guidelines). Maybe you should consider to remove the cells at all and if you do need them again, add them?

Related

The correct way to user custom UITableViewCells

I have seen a lot of different ways of implementing custom cells in a table view.
Like different file owners, get it from bundle and call the the latest obj of the array and a lot more.
But all did not feel right.
What is the best and correct way to create and use custom table view cells (with interface builder).
I think Storyboards are the new proper way. I use this method:
http://iphonedevelopment.blogspot.com/2009/09/table-view-cells-in-interface-builder.html
And it works quite well. I think it's somewhat proper in that you are asking the OS to do most of the work, although it's a little sneaky that the cell is assigned to a property as part of the NIB loading as a side effect.
Had the same problem. For me it is now solved with storyboards in ios5.

avoid dequeueReusableCellWithIdentifier to prevent UITableViewCell freezing

I am creating a custom UITableViewCell in which I am populating the cells with a JSon response of a web service. The problem is that the cell contains UIImage also which is creating problems when we scroll the cells (you can say freezing because of loading). I want to know the best practice of avoiding this behavior and also I want to know that is there any possibility that we don't use dequeueReusableCellWithIdentifier so we can prevent dequeueing of our cells.
Regards.
I found a good solution to accomplish this by using HJCache Library. Have a look at this and up-vote if you like :). Here is the link > HJCache Library
Happy Coding!

Adding data to a scrollview/table

I have an NSCrollView that contains an NSTableView. It has 3 columns and 4 rows. I have 4 NSStrings with content that I need to copy into the scrollview.
Using Xcode 4 I tried connecting the table or the NSTextFieldCell and then adding the text via
[_Cell1 setStringValue:MyString];
But nothing happens. It doesn't get updated.
Any way to do this?
Thank you.
EDIT:
I found the following answer to a similar question. I still am confused but after reading Apple's example about bindings I can only say that this does not make any sense, so much code to achieve something so simple. That's the problem with everything being an object and with OOP in general.
Any simple samples out there? I don't even know how to start setting this or connecting the gazillion things you need to connect to start working with this
You should use the NSTableViewDelegate. That's a set of methods the NSTableView calls to get the data that it should display. You just have to declare the delegate object of the tableview.
Delegate Protocol
NSTableView Tutorial
Unfortunately, you can't "add" or "set" the content of a table view. Like most view objects, a table view doesn't store content; it depends on a controller to provide content when it needs it.
There are two options:
Data source: simplest, easiest to understand
Binding to an array controller: harder to understand, but less work to implement
The best Apple resource on the subject: Populating Cell-Based Table Views from the Table View Programming Guide. If you're struggling, I suggest you start with the data source option. It'll be just a few lines of code, and you can adapt the simple samples from that document.
To populate the table, you need to implement these two methods:
– numberOfRowsInTableView:
– tableView:objectValueForTableColumn:row:
And to change the data, you'll need to implement one more:
- tableView:setObjectValue:forTableColumn:row:
You'll need to set your controller as the data source for the table view in interface builder. And the correct protocol for this is NSTableViewDataSource, not NSTableViewDelegate.
You could use an NSArrayController and bind the table columns' value bindings to the array controller's arranged objects. Then add the values you want to display to the array controller.

cells in tableview

i need to develop table view for entering text data and boolean values, so i need to implement checkbox functionality for some tableview cells, i know how to implement regular tabledatasource interface for supply the data^ what about different types of cells? Thanks, alot.
Have you tried implementing your own UITableViewCell? You could also "manually" create one in the data source delegate but this sounds like something that could be re-usable.
There is no big difference between data types. If you are confused with C types (int, bool etc.) keep in mind that you can always wrap them with NSNumber and pass as id where needed. If the question is in cell class itself - NSButtonCell with checkbox cell is the choice. It's available in the Interface Builder.
However, I'd recommend you to use NSArrayController and bindings if it is suitable in your task. Binding is simpler way to fill the table with data and there is no need to convert c <-> obj-c data manually.
i think that what i need - tableView:dataCellForTableColumn:row:
thanks to all

Attributed strings in UITableViewCells without WebView?

does anyone know if there's a way in with 3.0+ to display attributed strings within a UITableViewCell without using a UIWebView for that? I need to display a string with linked, tappable substrings as the typical detailTextLabel. I wouldn't mind exchanging this UILabel against another type of view, but I think a UIWebView could be just too slow when rendering a table with hundrets of cells. Or does someone have opposite experiences here?
So my question is: what's the best way to achieve mixed strings in a very large table without a great performance hit?
I searched for this almost a whole day now, but I can only find old posts mentioning that there's no attributed string on the iPhone (outdated, as this was pre-3.0) and/or saying that they use a UIWebView for that. But really, I don't think this would perform very well on large tables, would it?
Many, many thanks in advance
Arne
NSAttributedString has valid use only since 3.2.
But you may use TTStyledTextLabel from three20.
You can create your own view and put it in the cell.
Have a look at Apple doc related to UITableView, I linked the section "A Closer Look at Table-View Cells" which has lots of examples how to modify UITableViewCell.