Attempting to write a delete function. I am building an app to list courses after a button is clicked. I am using a text view to display this information and appending each course with a new line. Now i want the user to be able to delete a course. I was thinking if i can keep track of which line the user is on right now, then i can also tell which line the user will like to delete. Thoughts? Maybe there is a better way of doing this, perhaps using labels instead of text view?
EDIT: Use table view /s
You should use a UITableView to create a section for "Courses" and create rows in it with your courses.
And you should handle the insert/delete with the UITableView methods.
Check this out, or similiar tutorials out there.
Perhaps you could use a UITableView to achieve this. One benefit to using a UITableView is you can use built in functionality for deleting and creating new items. Here is a guide on UITableView.
Related
I've used UITableView before and like the way that the user can add a practically unlimited number of cells by entering information and the program uses a template. I'm wondering if there is a way to do this, but instead of using a table, using regular views or even buttons. For example, the user would tap a button, enter information, and return to the first ViewController and it would have a new view with the information in place of parts of a template that I designed.
Sorry if this is unclear. Basically I'm wondering if there is a way to make a table that is not as restrictive as a table, but uses several individual views in place of cells.
You can create re-usable views in the same way that you can create prototype cells.
Just right click in your project window, add new file and select User Interface > View. create it just like you would a prototype cell.
Then create a related class by adding a new swift file, link the two, create any outlets or actions you need and add any required logic.
Once you are done you can just load it wherever you need it, like so
self.headerView = NSBundle.mainBundle().loadNibNamed("HeaderView",owner:self,options:nil) as! HeaderView
You would likely need to pass in some required information, or setup the views frame or constraints.
I found a YouTube Video which should help guide you through the process. I've only skimmed through it so you may need to look around for a better one, but the general concept seems to be there.
im new in ios development and i want create a profile page with UITableView i tried Google, but i didn't find anything :( Assuming that i have 1 field (Name) on UITableView, when i click on "Edit" Button, i want the TabViewCell to became a UITextFields to let me edit the data. And then when i click the "Done" Button the UITextView became a TabViewCell again with new Value, All i can found as tutorial, is just how to delete, add or move a cell.
Does apple have an api for making editable forms in iOS?
No, there's no API specifically for creating editable forms, but UIKit certainly provides all the tools you'd need to create editable content of all kinds. Instead of relying on tutorials to show you the solution to every problem you need to learn how to use the API that's there to construct the user experience that you imagine. Until you do that, you won't be able to implement any original ideas.
Using a table is a reasonable way to create the form you want. Consider using a different type of cell when the user hits the Edit button. So, when Edit is tapped, reload the table content using the editable cell types instead of the normal ones. When they hit Done, record the changes and then reload again using the non-editable cell types.
I am having an app in which I want my view to be loaded like shown in the screen shot below.
The following view contains page control to show multiple images,buttons,labels,resizable text view and resizable text field in a single cell of table view.
There will be number of rows in a table view and rows will be generated dynamically.
Is there any cocoa control or tool which can give me functionality like this?
I have searched on cocoa control and goggled it a lot but couldn't find any matches to achieve this.
I thought of taking different views with sub viewing it didn't get much idea of how to generate it dynamically.
Please help me if someone has achieved this kind of functionality in any of their projects.
Thanks in advance.
Hint :
Divide each items in cells for single section, that means, one section for one item.
for e.g.
User photo, User name, User location and Post time in one cell.
Image gallery in another cell with page control on it.
Favourite (liked) post, comment on post and price in individual cells.
what you've to do is, create and add each item in a cell. While you're giving the height of each cell using delegate, check for conditions for which you're assigning the height. For e.g. if you've likes for the post (favourite) then only give height for that cell otherwise pass 0 (zero). Do the same for everything or as per your requirement.
For comments, you've to calculate text height, and based on that, you'll need to set height for comment cell.
References:
Here's a nice tutorial for this (not exactly) stuff. Rebuilding Instagram Feed Table View. I also googled a lot and found this, https://www.cocoacontrols.com/controls/stxdynamictableview, you may also need https://www.cocoacontrols.com/controls/mhpagingscrollview for showing image gallery.
P.S. This is not a "lunch plate" of course you've to make it for your self. Get hands on the keyboard! :)
Good luck!
I have in mind following behaviour for my table view controller. It is a table view to show to do items, just like a tasks list. I want to know if it where possible to drag down the whole table view and hold it in this position, and while in this position the user could enter a voice command that should be stored as a sound file in a core data entity.
Any proposals and help is welcome.
There is a project that implement PullRefresh, but you can use this to do another stuff.
Take a look to EGOTableViewPullRefresh
I'm writing a app that contains quite a bit of input fields for collecting data.
and im wondering what are some good methods to display these kind of input fields, if there are too many to fit on a screen? so something like the add contact screen... where u can scroll down and there are fields there
my initial idea is to put them in a scroll view and then i can scroll through them, is there a tutorial to do this? it seems like the scroll view is more for dynamically displaying data like a text view, and not for static forms like i was describing.
if anyone has any different methods for doing this please post.
UITableview will match perfectly for what you need.
My friend wrote this which is a container view that automatically helps with moving fields out of the way of the keyboard - It will certainly save you some time if you don't want to use a UITableView:
https://github.com/mackross/GTKeyboardHelper
The other way as H2CO3 suggested is to use a UITableView. If it is a UITableViewController, then you get the moving out of the keyboards way automatically. You could build custom table view cells that are styled to have a prompt and a UITextField for input. You can also set the selectionStyle to UITableViewCellSelectionStyleNone to prevent these cells from highlighting when selected.
I think the third way is to do this with a UINavigationController (or a UIPageControl) and build a kind of wizard, where you go through various pages of related data. This might be the neatest way depending on how many fields you have and if you can group data into common sets (e.g. personal information, work information etc)
I had the same problem and found GTKeyboardHelper to be an easy way out.
After drag and drop the framework in your project, include the header file.
Download and open the example project, then drag the "Keyboard Helper" object from the objects section in the xib to the objects section in your project's interface builder.
Drag and drop all your views to be children of the "Keyboard Helper".