Check for section index titles from table view cell - iphone

I have subclassed UITableViewCell and I need to draw my own disclosure indicator. The position of the disclosure indicator depends on whether or not the table view has section index titles set (the "scroll bar", typically the alphabet).
Does anyone know of a way to check if the table view shows section index titles from the cell?

Checking this from the UITableViewCell subclass would require a big deal of coupling with the UITableView class, so I suggest you take an alternate route - add a BOOL variable which you set in the cellForRowAtIndexPath: function and then call a function on your cell that will draw the disclosure indicator according to the value of the variable.

Related

How to change the outlet of the TableViewcell when table is reloaded

Im making anApp which has a address which has a listing page and a detail page .
If i click on email address of the detail page , it pops to the listing page. i want to show a tick on the listing page whose email is selected.(like shown below). The cell has a image (tick)
.I want change the outlet of the image in the cell when the lising page is reloaded. The cellforrowatindexapath is obiously not called when table is reloaded.Is there any way that i can get the index path of the cell .so that i can change the outlet of the cell when table is reloaded.Thank you....
Why don't you change the accessory view type?
Set the accessoryViewType property on UITableViewCell to one of:
UITableViewCellAccessoryDisclosureIndicator
UITableViewCellAccessoryDetailDisclosureButton
UITableViewCellAccessoryCheckmark // you want this one
The default value is UITableViewCellAccessoryNone.
You may have to called [tableView reloadData] when appropriate to reload the table data.
There are lots of questions on SO relating to accessory views, e.g. custom accessory views: Using a custom image for a UITableViewCell's accessoryView and having it respond to UITableViewDelegate for example.

How do I initialize a UITableView in the middle of the table

How can I initialize a UITableView so that it starts off showing something (of my choosing) in the middle of the table, rather than what is at the top? I want to have a certain cell in the table always start at the top of the screen, so you could scroll up or down from there.
You can scroll to a certain cell by sending - (void)scrollToRowAtIndexPath:(NSIndexPath *)indexPath atScrollPosition:(UITableViewScrollPosition)scrollPosition animated:(BOOL)animated to the table view.
As you have described you want the cell of your choosing to appear "in the middle of the table", so you should use UITableViewScrollPositionMiddle for the scrollPosition argument.
If you do this as soon right after your table is initialized or as soon as your view loads with the animated argument set to NO then the table view will appear with your cell in the middle, just as you've described.
You also write: "I want to have a certain cell in the table always start at the top of the screen".
By instead choosing that cell and the scrollPosition UITableViewScrollPositionTop you can make that cell be at the top of your table view.

pop up detail view out of tableviewcell

I am working on a app where I want to expand a tableviewcell to cover almost all the screen with animation when it is selected by user. I am looking to create a uiview on the tableviewcell and expend it to cover major portion of the screen when user selects the row.
The main problem I am having is to get the frame from where my pop up view will start expending. How will I get the frame of the row which is touched?
Thanks
Pankaj
Is it crucial that the cell should not reposition?
If not ( i am guessing not, as you are anyway planning to cover whole screen):
When the cell is selected, scroll the cell to top (using scrollToRowAtIndexPath) and either insert your custom view to cell's contentView or modify its parameters if its already there with different opacity/size etc
Use UITableView function to get the rect for the row by passing the its NSIndexPath.
- (CGRect)rectForRowAtIndexPath:(NSIndexPath *)indexPath

Insert ScrollView in TableView?

I have a TableView with one cell and I want to insert in this cell a lot of text so I think I'll need to use a ScrollView for scroll the text.
How can I insert? Is correct this method?
This is a help in the application, is correct use this modality?
Sorry but I'm a beginner and I don't have an iPhone or iPod, thanks!
While I concur with 7KV7's original comment, it doesn't look like there is need of a tableview in this scenario...
Just in case someone else happens upon this looking for an answer to the "Scrollview in a Tableview" question here are few clarifying points for the above comments.
The technical problem with having a tableview and a scrollview together on the same view is that UITableView is already a descendent of UIScrollView and if you attempt to handle both in the same view then you will end up with quite a mess with conflicting delegate messages.
As suggested by iPhonePgr, you can create a custom UITableViewCell. The first thought would be to let the UITableViewCell act as the delegate for it's own scroll view. The problem here is that the cell and it's contents could be discarded or reused at any moment as part of tableview's dequeue functionality.
So some ground rules to guide your implementation:
Whatever your solution, you're probably going to end up making a custom controller class, possibly derived from NSObject and implementing UIScrollViewDelegate.
The custom controller object acts as the mediator between the model object and the cell.
You will probably have an array or array-of-arrays that mirrors the model hierarchy driving the UITableView structure.
Because the cells can be discarded at any time you will have restore the scroll view state on cell initialization and preserve the state has part of handling your delegate actions or through a custom UITableViewCell implementing prepareForReuse.
Hopefully these points will come in useful to anyone who runs across this entry.
You need to create a custom cell by inheriting UITableViewCell and then add UIScrollView in the customcell. Then Use that cell in the Table view.
you can put your text in UITextView and add it as a subview in your UITableViewCell,because
UITextView is inherited from UIScrollView,
No need to add UIScrollView if you use UITextView
When you create UITableView you implement a number of delegate method which you can see by pressing the window key and then double clicking the UITableView delegate . In one of the methods you can set the cell height as per your requirement. By doing this your cell height can vary.
- (CGFloat)tableView:(UITableView *)resultTableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 150;
}
As your table has a defined height, when the text in cell will be too much to contain into a scrollview will be automatically inserted.

How to add UITableViewCellAccessoryCheckmark in the middle of the cell in iphone?

In my iPhone application I have used (UITableViewCellAccessoryCheckmark) to add the checkmarks in the cells, - it is added to the cell at the right side of the cell.
I want the checkmarks to display in the middle of the cell and after that a string should display. So that the user can set the cell item as checked or unchecked.
Please provide any solution or any code for adding the (UITableViewCellAccessoryCheckmark) in the middle of the cell.
There is no built in way to do this. You will have to create a cell, then in tableView:cellForRowAtIndexPath: you will need to either add a custom subview, or return a custom cell and tell it to display the custom checkmark you added based on the data state.
The accessory view of the cell is always on the right side, outside of the cell's content view (see the Table View Programming Guide for more on this). If you want to do something like this, you really need to create your own cell class, and draw the checks yourself.
Speaking as a user, this design seems sort of confusing, and definitely not what I'd expect. What's the string you're displaying to the right of the check? Maybe something like the UITableViewCellStyleValue1 style cell would work, instead? (See Standard Styles for Table-View Cells for more.)