I'm writing an app in which there will be user defined "categories" which will consist of a label and each category will have a user defined list of "items" which will be UIButtons. I want a user to be able to layout the user interface to their choosing. What's the best way to implement this? Any example code out there?
Edit: Just to make myself clear, I have groups of buttons with a group "heading". I'd like users to be able to move these buttons around inside a group and also to arrange the groups as a whole. It's okay if they have to enter some sort of "edit mode" to move things around.
Probably the easiest way is to use editable UITableViews with UITableViewStyleGrouped style (just like Settings.app). Then you can add, remove and arrange items inside groups. You can show it as "edit mode" view.
Here are some useful posts about it:
iOS 5: Drag and Drop Between UITableViews
Tutorial on How to drag and drop item from UITableView to UITableView
iPhone UITableView Tutorial: Grouped Table
You could use touch handling methods to enable drag-drop type of rearranging of buttons. UIPanGestureRecognizer is a useful class for this. A reference for this can be found here.
Related
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.
I am creating an app that would have many categories at the top for filtering (as in I would have items with tags, and I would want to filter items by their tags). Originally I was using scope buttons but that is not user-friendly/visually appealing for many categories. Do you have any suggestions, advice, or existing projects that use a different UI? Any help would be greatly appreciated!
You can use scroll view horizontally to show your cat1, cat2, cat3, etc...
main view -> scroll view -> buttons for cat1, cat2, etc....
You can add buttons at run time and set a action.
There are many open source horizontal category bars are available, please search on Google.
Hope this helps.
A UICollectionView is probably the way to go. You can have lots of customization in the presentation, including size and flow. For tagging you could have a custom UIView that renders as a tag and exists within the Collection.
Often people use them for image collections, but you can collect most anything that can be rendered as a UIView subclass.
Right now i am developing app. One of it's ViewControllers has tableview with list of blog posts. I want to put some control so user can select blog's categories and then app will show posts only from those selected categories.
I thought it would be nice if there will be "filter" button in top right corner of my app's viewcontroller. After pressing it dropdown list of category appears and user can select categories.
What custom UI element can handle it?
Really there's a ton of options at your disposal, not including all the custom elements you can probably grab from GitHub
For an iPad, you can use a UIPopoverController https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UIPopoverController_class/index.html
Depending on the number of filters and the style of the design, a good starting point could even be a UIActionSheet.
If you want to do something really fancy, you could have a second UITableView hidden underneath by your main UITableView containing the blog posts, and then when the "Filter" button gets hit you can animate your blog UITableView slightly over revealing your filters menu (maybe even shaded slightly darker to give a feeling of depth to the app)
I searched for a while and can recommend CZPicker https://github.com/chenzeyu/CZPicker because it very nice and easy picker view for iOS that supports iOS 7 and is well working not only iPhones but whit iPads too.
How can I make a drop down menu in my swift IOS app that has different options that the user can select, whatever they select displays in a label above the menu. Example: drop down menu to select age in an app. Or like the select size and quantity option in the following link http://store.nike.com/us/en_us/pd/roshe-run-shoe/pid-463712/pgid-943980.
Please let me know if you can help me accomplish this, Thanks!
I achieved similar feature on Objective-C, hope the same concept can be applied on swift.
I actually subclass a UITableView with some customized functions and variables, then instantiate the class with desired coordination and dimension and use UITableViewDelegate methods to trigger the events needed.
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".