looping through uitableview sections to change section header frame - iphone

I have a grouped UITableView with many sections, however, I want to iterate through these sections after i tap a UIButton, so viewForHeaderInSection is useless in this case, I want to iterate through sections to change their headers frames, Im struggling to do it but to no avail until now.
I'd be grateful to anyone who helps me with this.

viewForHeaderInSection gets called every time you call ReloadData on a table view.
So you could have a Boolean that gets set to yes every time your button is pressed, and also call reloadData in the button's action. In viewForHeaderInSection, check the value of the bool, if it's true, set the size to what you want when the button is pressed, if false set it to the normal size.
I hope this helps.

After you header view's datasource iterated and changed in whichever you wish way, call
[mytable reloadData]
And your header views are redrawn. Simple and clearly you have not tried that before asking, next time do it.

Related

How can I stop reloadData on my UITableView from clearing the delete confirmation button?

So I have the following:
A UITableView with deletable cells (the kind where you swipe the cell then click the delete button)
The UITableView's properties (eg. a UILabel) are automatically updated (with a reloadData call on the UITableView) every second by a NSTimer (this is required)
The problem is that the reloadData call clears the delete button after swiping (within a second of course). How can I keep this from happening?
Thank you!
u can keep a boolean flag variable that becomes true if the delete button is visible and false if not and in the place where u call reloadData u can check the flag value and function accordingly
When the user swipes a UITableViewCell, tableView's isEditing property will be set to YES. You should check this property before you reload your table.
All I need to do was to set the UILabels text property from the NSTimers invocation method call and it doesn't even require a reloadData call to update the UILabel...

custom uitablviewcell does not call didSelectRowAtIndexPath in the controller

I have a custom UITableViewCell completely written in code (no IB), it has an accessory button that simply calls didSelectRowAtIndexPath on the table view, and it works correctly and the method is called without problems.
However, when I tap on the cell itself (not on the accessory view) nothing being called, why ?
EDIT: the code is huge to put here ... however, the custom cell contains a ton of labels, couple images and scroll view ...
This is a shot in the dark, but if each cell has many different objects on it (i.e. images, labels, etc) then it may not be working because those objects are what the user is hitting when they try to click a cell. Does the cell turn blue (indicate selection) at all? If not, try hiding/removing those objects for now and see if it works.
If that is the case, then what you may want to do is create an invisible cell or button that sits on top of the other objects and calls didSelectRowAtIndexPath from behind the scenes.
This should solve your problem:
Raise selection event (didSelectRowAtIndexPath) when subview of UITableViewCell is tapped
Try setting your view's userInteractionEnabled property to NO.
This will make it ignore all touch events, and then the views under it will be able to catch these events. - Felipe Sabino
I'd partially answer my question: the wide scroll view is preventing the cell from calling didSelectRowAtIndexPath, removing the scrollView will solve the problem, however, I want to call this method with the existence of the scrollView ... anyone got ideas would be highly appreciated ...
You must post your code to understand what have you done...You have to check out this example to understand whether your code is correct or not...
http://www.edumobile.org/iphone/iphone-programming-tutorials/impliment-a-custom-accessory-view-for-your-uitableview-in-iphone/

iphone tableview scrolling issue

I have a tableview with imageviews and textviews in each cell. When my view is loaded one of the textviews is invisible. But when I start scrolling the textview appears, so that my view looks as it is supposed to look. Does anyone know why this is happening?
P.S. I have read about reusing cells when scrolling so I have been very careful to construct my cells correctly.
Without code, no one can give you a exact answer. But for a guess....
Is your data is getting populated after your table call cellForRowAtIndexPath? When the cell populates the first time, no data, so the cell is in it's unformatted state. By the time you can interact with the table and scroll it off and on screen (which calls cellForRowAtIndexPath again), the data has been populated and so the cell looks as expected.
You can test this by putting a breakpoint in your cellForRowAtIndexPath method and check to see if your data objects are initialized or still set to nil.

iphone sdk stay the selection colour of cell in UItableview?

How to get the selection cell still in the selected state in uitableview. Actually I am pushing a view from a tableview when came back then the selection cell is deseleted. I want to be show the previous selection cell when came back also how to do that.
In didselectrowatindexpath use the method selectRowAtIndexPath:animated:scrollPosition: and the row stays selected.
when you are going and coming back from anotherview make sure that save the selectedCell and then in viewwillappear method reloaddata.In cellforindexpath write the code of selection style uitableviewcellselectionstyleblue.
first, you can store the selected indexPath in user default in the didSelectRowAtIndexPath method.(maybe you can store a indexPath that is bigger than your table view's row count to indicate initialization stage, which means that no row has ever been selected)
then, you can load the stored indexPath in the viewDidLoad method using
tableView selectRowAtIndexPath:<#(NSIndexPath *)#> animated:<#(BOOL)#> scrollPosition:<#(UITableViewScrollPosition)#>
meanwhile, you can do some check (like mentioned above or something else) to check if there's nothing selected yet.(saving a bool in user defaults works, too)

iphone segmented control and uitableview

I have a UITableView with a segmented control at the top. When you tap on the different segments, I want the table to reload with a new different sized array. I have tried everything including [self.tableView reloadData]. When you click on a different tab now, it only changes the cells that are out of view and does not add any more. Any ideas??? Thanks.
In your numberOfRowsinSection method, are you returning the count of the correct datasource when the segment selection is switched? When you select a segment, you would need to call 'reloadData' on the tableview, you would need to check the count you are returning from 'numberOfRowsInSection' and you would need to use the correct datasource in cellForRowAtIndexPath to provide your cell contents.