Unload specific UITableViewCells - objective-c

Is there a way to unload/release a UITableViewCell such that the containing UITableView calls cellForRowAtIndexPath: when it is needed again?
I understand that this is exactly what UITableView does by default, but only once the cells are outside the tableview frame. My custom view uses UITableView in such a way that its frame == content size.
If there is no way to unload specific cells, I'll have to think of a different approach.

The method [UITableView reloadRowsAtIndexPaths:withRowAnimation:] allows you to tell the table view to reload one or more cells. This will reload the specified cell(s) if they are on screen and presumably do nothing if they aren't currently on screen. Sounds like what you want though your question is not entirely clear to me.

Related

How to update UITableView after adding/ updating data

I am newbie for iPhone application. For storing data, I am following this tutorial.
I understand how to save data and retrieve the same.
What I am wanted to do is instead of another UITableViewController (first screen in storyboard, where we have list), I will drag a UITableView and show list of items there instead of showing in another screen.
Any idea/ suggestion how to get this done?
Any hints would be greatfull.
What I feel is, I would need to add UITableView. Add delegate and dataSource method on it and add a method where I will have all data shown in UITableView.
Edit 1
What I want is ONLY ONE SCREEN. In the link that I have provided, it is second screen.
That should work fine. But make sure you also have done a
[tableview reloadData];
after you've changed the data in your table view data source delegate.
What I am wanted to do is instead of another UITableViewController (first screen in storyboard, where we have list), I will drag a UITableView and show list of items there instead of showing in another screen.
Why you want to do this way?
UX will not be at best.
What I feel is, I would need to add UITableView. Add delegate and dataSource method on it and add a method where I will have all data shown in UITableView.
Even if you want to do, yes you need to set delegate and datasource methods.

UITableViewCell Height Calculation and delegation?

I know this question had been asked hundreds of times before, but it's never really been solved (Or at least the way I'd like it to be). I have a rather complex UITableViewCell setup. The cell.backgroundView is loaded from a UIView subclass which uses a fair bit of CoreGraphics and CoreText. The code is rife with CTFramesetterSuggestFrameSizeWithConstraints, so I'm relectant to duplicate the class in the heightForRowAtIndexPath method.
I think I can solve this by creating an NSMutableDictionary with the indexPath as the key and the height as the value. But then I'm faced with the problem of heightForRowAtIndexPath being called first. I believe I can solve this problem by guessing the height of the cell and then once the cell's UIView subclass has finished rendering, use delegation to set the cell's height.
But this leaves me with the problem, how the hell do I delegate this? And, how to I prevent scrolling from being extremely choppy? as the cells will be created and resized in a split second.
In the past, I've used a dummy cell. I have a separate method -fillInCell:forRowAtIndexPath: which puts data into the cell. That way I can fill out the dummy cell in -tableView:heightForRowAtIndexPath: and the real cell in -tableView:cellForRowAtIndexPath:.
If this does not work for you then there are other options.
The first thing that comes to mind is create real cells in -tableView:heightForRowAtIndexPath: instead of -tableView:cellForRowAtIndexPath:. You can store completed cells in a mutable dictionary. -tableView:cellForRowAtIndexPath: will simply pull the completed cell from the dictionary. You should also detect when scrolling has stopped so you can empty your dictionary (just because -tableView:heightForRowAtIndexPath: was called doesn't mean -tableView:cellForRowAtIndexPath: will get call for the same indexPath).
Hope that helps.

UITableViewCell Accessory Views Duplicate In Defferent Sections When Scroll The UitableView

This question make me troubled for a long time, I want to implement defferent accessory views on different cells in my tableview.
And my tableview have multiple sections, But they duplicate onto other cells in my other sections that I have not implemented when I scroll up and down the UITableView. I know someone said "It should be Use different identifiers when you assign dequeueReusableCellWithIdentifier: for each cell in cellForRowAtIndexPath: method before,
But I don't know how to implement programmatically in detail, Anybody can write a sample code in detail help me to understand?
Thank you very much!!!!!
Its all well and good to use different accessory views. But you have to keep in mind that if you are recycling cells, then you first try to recycle, if none available you create a cell, THEN you need to set the appropriate accessory view for the particular cell you are going to return. Who knows what the old one was for a recycled cell...

What is the alternative of visible true/false for views in cocoa-touch?

I'm customizing a tableviewcell which is still very hard to me.
After reading apple's guide, I'm customizing my cells by loading them from a nib file, and managing them programmatically.
so instead of creating two different types of nib files (tableviewcells) one with textfield, and another with pickerview.
I'm doing a hybrid cell. i.e. In my nib file, i'm adding a UILabel, UItextField, UIPickerView.
Now on the 'cellForRowAtIndexPath' for the tableview (after i've bound each cell to the nibfile)
i want to be able to programmatically use the pickerView OR the textfield.
Now there's no 'visible' property to use in order to show one and hides the other.
So what's the best approach here.
I'm a bit new to cocoa , and the framework is not giving me many options.
So for example if indexpath is 0.1 i want it to be a pickerViewCell.
and if indexPath is 0.2 , i want it to be a textfieldCell.
So if indexpath is 0.1? what should i do?
should i dispose of the textfield? change its coordinates to somewhere that can never be viewable? disable it? what?
and if my approach is wrong and not recommended, what is the recommended way?
should i go back and remove the pickerView from the nib, and create another nib file with only label and pickerview? and upon loading decide which one to load?
Thanks
View visibility is controlled by hidden property (that is - the opposite of visible) - you can use it in your case

Is there any way to place two UISearchBar in UITableView?

I have a UITableView with customized UITableViewCells, now i have already placed one UISearchBar to find one of the data in UITableViewCell and it is working fine.
Now i want to do search operation for the other data which is placed in UITableViewCell, so is there a way to place another UISearchBar programmatically?
Yes. It's totally flexible. You just need to create the cell and you can control the placement using the UITableViewDataSource/Delegate methods.