How to delete cells from UITableView? [closed] - swift

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I want delete an object from my a tableView without commitEditingStyle like iOS Music App! I do not need a swipe to delete function! How to delete cells without commitEditingStyle?
Thanks

First, remove an associated item which is related to a cell in your datasource, and let's assume you are removing the sixth row in the first section.
let indexPath = NSIndexPath(forRow: 5, inSection: 0)
self.tableView.beginUpdates()
self.tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Automatic)
self.tableView.endUpdates()

Related

Swift - TableView How To Create Expandable Section [duplicate]

This question already has an answer here:
Expandable Sections UITableView IndexPath SWIFT
(1 answer)
Closed 6 years ago.
I want to create a expandable section with swift. For example in the picture below, Microsoft Outlook IOS application has a expandable section.
When you click to the section , it seems like below.
Is this section needs extra code or xcode already has a feature for this? Thanks in advance.
You need to create a delegate for the custom section you have created, assign it to the ViewController and in the delegate method call this when the user taps on it.
insertRows(at indexPaths: [IndexPath], with animation: UITableViewRowAnimation)
and when the user taps again on the section check if the section is open, if yes then call this method.
deleteRows(at indexPaths: [IndexPath], with animation: UITableViewRowAnimation)
And don't forget to call tableView.reloadData() after these methods.
I've recently used the same in one of my project but it was in objective-c, i know one something which will help you. Please have a look,
Swift Expandable Section
I hoe it will helps you.
Thanks.

creating a profile to add to a UITableViewCell [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I want to have the ability to allow the user to fill out a profile, almost like the notes app and then when they are done it adds it to the UITableViewCell and displays certain parts of what they filled out on the Cell..Then they can obviously repeat this action..
I am not sure where to look for a tutorial on this or what this may be called, anyone have any suggestions?
Five simple steps :
1)Design how form is gonna look like and your tableview.
2)Make the form using a sample UIviewcontroller layout your components using xib or
storyboard
3) Embed your UIViewcontroller designed in step 2 into a UINavigationViewController
This helps you to transition from your form to UITableView
4) Design your UITableViewController and put a back button on UINavigationBar to allow user to go to previous view controller.
5) Connect UIViewController to UITableViewController
-(void)submitButtonPressed:(id)sender{
UITableViewController *tvc = [[UITableViewController alloc] initWithNib:#"your view controller name"];
// pass data to UITableViewController
tvc.userdata = self.userdata;
[self.navigationController pushviewController:tvc];
}

IOS: Adding Overlay Image on UICollectionView Cell [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Improve this question
I'm using UICollectionView to generate a image gallery.I used UIImage inside the UICollectionView Cell to load the images. I need to select UICollectionView Cell by Long Press (not by single tap).
Just pick up the didSelectItemAtIndexPath delegate callback, grab the cell, and add an image as a subview.
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
YourCollectionViewCell *cell = (YourCollectionViewCell*)[collectionView cellForItemAtIndexPath:indexPath];
UIImageView *yourImageView = [[UIImageView alloc]initWithFrame:CGRectMake(x, y, width, height)];//whichever frame you want it to appear at
yourImageView.image = [UIImage imageNamed:#"yourImageName"];//set the image
[cell.yourBaseImage addSubview:yourImageView];//or add it to whatever part of the cell you want
}
Or alternatively, just have a hidden imageView already setup inside of Storyboard. And then unhide it and set the image inside didSelectItemAtIndexPath.

legacy cell layout due to delegate implementation of tableView [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
WARNING: Using legacy cell layout due to delegate implementation of tableView:accessoryTypeForRowWithIndexPath: in <Settings: 0x250c60>. Please remove your implementation of this method and set the cell properties accessoryType and/or editingAccessoryType to move to the new cell layout behavior.
Here,
accessoryTypeForRowWithIndexPath is deprecated in iPhone OS 3.0.
Instead set like this.
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
Existed Answers - here

Creating a combo box for the iPhone [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
Since there is no pre-existing component for creating a combobox (or select box) as seen on webpages through Safari, can someone provide an example or pre-existing 3rd party component of creating one?
I don't think this is hard to do.
In a view controller you have a UITextField and a UITableView. Assign the view controller to be the delegate of the both controls, plus the data source of the table.
Implement the UITextField delegate method textField:shouldChangeCharactersInRange:replacementString: in your controller. This intercepts the changes as they are being typed in your text field. In this method, iterate through your list of possible options and store the matches in an NSMutableArray instance variable on your view controller. Then call [myTableView reloadData].
Have your table cells generated from the array of matches you previously stored.
It should be pretty straightforward and shouldn't take much code at all beyond a few delegate methods to get working.