I was just wondering if it was possible to remove the button that is automatically added to the UItableview cell when creating a segue in storyboard between the cell background and the destination view. For my app, it takes up to much space. I'd rather the user just tap any where on the cell to activate the segue.
Does anyone know how to do this? When I select the button in the cell and hit delete, the whole cell deletes.
Try adding the following code to your cellForRowAtIndexPath method:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
cell.accessoryType = UITableViewCellAccessoryNone;
}
eddwinpaz answer is what worked for me (as I was using storyboard and not doing it with code)
"Select on storyboard Atributes inspector and select the tablecell you don't want it to appear the Accesory and then select Accessory: none"
Related
In my app there is a table view with custom cell.in that cell there are (image view, views and labels).data loads succuessfully to the table.
Then what I wanted to display another view(detail view) when user tap on the cell.
I did it by (ctrl+drag) cell and connect it with the detail(second) view.
and selected the segue kind as Show.so then,when I click on a cell first time it correcly and and then I have to tap twice to load the detail view. I tried with changing kind to show Detail, present Modally, etc.but the no successful result. Then I tried with using navigation controller within these views.but didn't get any successful result.no idea what to do.I added some code and if you guys want more code I can provide.hope your help.thanx
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
FlightRoundtripDetails *setDetails = [RoundItineraryArray objectAtIndex:indexPath.row];
resultCell.firstdepatairiportCodeLabel.text = setDetails.FirstDepartureAirport;
resultCell.firstarriairportCodeLabel.text = setDetails.FirstArrivalAirport;
resultCell.firststopoverLabel.text = setDetails.Outbound;
}
data display correcly.only the issue is when tap a cell.hope your help.thanx.
I think u have set the tableview selection as Multiple. So goto Attributes Inspector and change the selection to Single.
How would I go about adding several buttons to a tableview to each cell? I need to add a comment and like button to each cell in my tableview and each button will have to be specfic to the row being clicked. How do I go about doing something like this ? Do i place a action inside of
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
or is there a way to programatically set a button to a ibaction from inside cellForRowAtIndexPath that allows me to send parameters?
You can create custom table view cell and add multiple button.
1. Create class that subclasses UITableviewcell with xib
2. In xib delete the view and drag a tableview cell into xib
3. Add multiple buttons in xib
4. Create IBOutlet for each button.
5. In your view controller import your CustomTableViewCell and in CellForRowAtIndexPath method add action for each method and set button tag as indexpath.row
6. Identify the clicked button's indexpath from it's tag
Refer this link
I think this is what you are asking...
[cell.button1 addTarget:self action:#selector(button1Pressed:) forControlEvents:UIControlEventTouchUpInside]; In the
receiver method you can get sender's tag
-(void)button1Pressed:(id)sender{
UIButton *button1 = (UIButton*)sender;
int selectedRow = sender.tag;
}
You need to subclass your UITableViewCell so you can customise it to your need.
There are a lot of tutorials about this. Depends if you are using Storyboard or not. Here is one of many: http://zeroheroblog.com/ios/how-to-create-simple-tableview-with-custom-cells
I have made a custom UITableViewCell, this cell has icons, labels and text views within it. I want to make the entire cell clickable but i can't make it work.
I use the following code to handle the click
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
This only works if you touch the cell where there are no textviews, how do i make the entire cell clickable?
It's My first time to post a question, thank you for you all in advanced.
Now, i want to implement a default style grouped UITableView contains multiple group of data. for each row, there will be a detail Disclosure button as accessoryType icon. when people click on the disclosure button, i want the Cell expand with detail info for the selected row.
i was trying to fulfill this task by add a customized cell to selected row, however, it was very complex. So currently, i am trying to finish this task by reload a specific row with Customized cell xib. i knew there is a delegate method for reloadRowsAtIndexPaths. but can i use this to reload a specific cell? Thanks
please suggest!
Great Thanks
Have you tried something like this:
(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if(indexPath.row == mySpecialSelectedCell)
{
//Load all your custom stuff here
}
else
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: CellIdentifier];
}
if (cell == nil)
{
}
return cell;
}
You would have to get the cell's indexPath when you click the expand button.
Or you could look at this answer. And then, like the code above, just load that one cell that you have specified with that NIB and load the rest the way you would normally.
You can implement the tableview delegate methods to set the height for the cell which needs to expand. Add some condition check in heightForRow method and when user taps on button, change the condition to increase the height. When table is reloading it will call this method and will reload cell with bigger height.
I have a tableview, where when the user selects the cell it will set the accessorytype to UITableViewCellAccessoryCheckmark.
Now when I navigate to the previous screen, then go forward to this tableview, my cells remains checked.
Is there a way to uncheck all of them? I guess basically set all of them to UITableViewCellAccessoryNone.
I tried using reloadData, when the view appear, but that doesn't seem to trigger the cellForRowAtIndexPath (this is where my logic is to set the accessorytype of the cells)
I think this may do what you want. I assume you want to uncheck all the cells as part of responding to tableView:didSelectRowAtIndexPath: but you could insert this code anywhere:
- (void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// Uncheck any visible, checked cells.
NSArray *visibleCells = [tableView visibleCells];
for (UITableViewCell *cell in visibleCells) {
[cell setAccessoryType:UITableViewCellAccessoryNone];
}
// Now do whatever else you want in response to a row being selected.
}
You should set the accessorytype in tableView:willDisplayCell:forRowAtIndexPath: instead of cellForRowAtIndexPath so that it is updated whenever it is displayed (and not just when created).
There is a tableview method called clearsselectiononviewwillappear that you might have accidentally overwritten. The default behavior should be YES. Check out Apple's doc
on UITab