How to customize a UITableview's index look? [closed] - ios

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
http://imgur.com/rxVYsV2 - reddit's index
I want to create an index similar to the one in reddit's app, especially adding icons to it and having it highlight the letter(see link for picture).
Any suggestions for how to do it(in xamarin ios)?

Since, you didn't ask for code, I'll just help you get started. :)
Use a UITableView to create a row, a cell would be like
Add another UITableView to create the side listing, with just an alphabet as cell. Something like
Now, on selection of any row from the second UITableView, modify the highlight and scroll the left UITableView accordingly. As well as on scroll of left TableView, change the highlight according to the first alphabet.
UPDATE
For StoryBoards follow the following steps:
Drag and drop two UITableViews in StoryBoard, place and resize them however you want (according to the layout you want), apply constraints.
Give each StoryBoard a reference like you do for other elements such as buttons etc. or give them a Tag.
In your ViewController make two Nested Classes, two of them for 1st TableView, one inheriting from UITableViewDataSource and other from UITableViewDelegate. Override the mandatory methods (link).
Now once you have the classes done, assign them to your TableViews like
//With Tag
UITableView myTableView1 = (UITableView) this.View.ViewWithTag(1);
myTableView1.DataSource = new MyTableView1DataSourceClass();
//OR
//With reference
myTableView1.DataSource = new MyTableView1DataSourceClass();
myTableView1.Delegate = new MyTableView1DelegateClass();
Please look at Create UI Objects for more help with making objects.
Please upvote and mark it as the correct answer if you feel it is. Besides, let me know if you need more help. Have a great time coding :)

Related

Should I reuse tableView cells when they have little difference? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
I just want to know which is the better way to do cell reuse
For example:
Cell 1:
Name
Detail
Time
Cell 2:
Name
Detail
Image
Time
The two cells, "Name","Detail","Time" are having the same position.
So, my questions are:
Shall I use one cell for reuse(modify constraint in runtime) or create two separate cells?
I think use two cell will have the better performance, but how to reuse the "Name","Detail","Time"'s auto layout in xib (If use code, this is easy for me, but my project use xib)
You have many options.
use stack view, then manipulating constraints is not needed to hide a element. Lets you only create one storyboard/IB instance and stack view handles hiding nicely.
use two unique cells, they can grow over time down separate paths as requirements change.
Or my preference
create cell subclass, lets say BaseCell, that loads object or
protocol that can supply name/detail/time, cell.load(xxx)
create a cell that subclasses BaseCell, say ImageBaseCell, that loads
an object that loads object or protocol that can supply
name/detail/time/image, handle image here, but super.load(xxx) will
handle the rest.
This does require individual xibs per cell subclass. However, this way, logic for handling name/detail/time is in one place, instead of several cell classes.
I would recommend for going with two separate cells. The table view datasource methods will take care of populating the cell contents rather than you handling the views inside cellForRowAtIndexPath method. Also if you're incorporating contents of varying sizes in the a cell, it is always better to go with multiple cells for cells having different contents.

What is the best way to design a form layout [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
What is the best way to design a form layout, I've tried using static UITableView, but I don't know if it's a good practice when I have many cells and if I use prototype cells, it's difficult for me to interact with the elements inside the cells.
Other form is without using UITableView only a UIScrollView, but I don't know which is the best form.
In short, which is the most used method for design a form layout?
EDIT: I need to achieve something as shown in the image.
EDIT2: In the case of a CustomCell have a picker view inside, it's better that the same cell delegate from the UIPickerView or it should be the viewcontroller that delegates from the pickerview?
Now my CustomCell delegates from a UIPickerView and the options strings array and protocol methods are inside that class, that's okay?, In that case, what can I do when the array is composed of custom objects instead of strings, for example, I have an array of Persons and I need to show in the pickerview the person name, but I need to return to the viewcontroller the person's age. In that case, I have to create other custom cell that manage that array type (and another different one whenever I need it to handle a different type array)?, or is there any way to unify that to avoid having to create many of different cell classes?.
The best method herein would still be to use UITableView. You can design your own custom cells which gives you better flexibility incase the form changes in the future.
If the cells have similar kind of elements and you want to reduce your workload for the auto layout stuff you can surely go for the UIStackView inside the custom cell you are designing as suggested by Donovan.
The main reason for the usage of the UITableView is that it gives you great flexibility in terms of grabbing the indexPath for a particular row. Even if the form increases in terms of the numbers of rows it needs to hold on to, you do not need to add a separate UIScrollView to the same.
If the design for certain rows changes, while other still being of the same design, you can still use custom cell and put in a different cell identifier to the new cells and use the "dequeueReusableCellWithIdentifier" and incorporate the new design.
Hope this helps!
Table views are generally used when you're displaying data to the user of some sort. For your case how about trying a UIStackView. Here is a guide to get you started.

Swift 3 - How do I implement an accordion-style layout? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I am using Swift 3, Xcode 8.2.
I want to achieve something like the look below:
I want a view where I can have a top heading and label and an intro paragraph along with a line separator but have this "accordion" style layout where users can click to reveal/hide different parts of the information.
Can someone point me in the right direction?
Since there's no actual accordion style layout in UIKit, there's no right answer, you'll just have to roll your own.
Here's how I've done it:
Create a sectioned tableview, each collapsable group of
information is it's own section. Each section should have a section header. Implement viewForHeaderInSection.
The header view could have a label that says 'Yearly Benefit Tracker', etc, and a disclosure image that changes based on whether the
section is opened or closed, like in your example.
Each section has a tap gesture recognizer associated with it.
When a tap gesture is triggered, the corresponding function adds that section to a set of 'collapsed sections'
Reload the table view
When number of sections is called it still returns all the sections
When number of rows is called check to see if that section is in the set of collapsed sections. If it's collapsed, return 0 rows for that section.
Implement the reverse for expanding.

Any ideas for realizing this "feature"? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I'm currently developing an iOS app for my company and I'm really new to app development. I have a styling guideline from our companys' art agency.
Here is an example of what I'm trying to accomplish.
As you can see on the pictures' bottom there a some "stacked" / "overlapped" panels (where the arrow is pointing at) The first one should have a title and content - the other two just an title. There should be no functionality (just by touching on them as a whole, to navigate to the detail view) - but I have no clue for realizing this.
I had a look at UIStackView but im not sure if this is the right control for doing this.
Is there a control for doing this, or do i have to place those views manually?
If you truly don't need any other functionality other than tapping on them you're going to have to layout three UIViews yourself like you see in the picture.
It looks like the top one is a UIView with room for a title Label, a time label (maybe?), and a detail Label. So start with a UIView, create your labels, and add them in one by one to the top view, taking care to set AutoLayout up correctly so the views are aligned like you see.
I would reccommend creating the back UIView first, then adding it, create the middle one, add it, then create the last one and add it. This way they will automatically be setup in the correct order "depth" wise
Edit: As you said your new, let met me add one more tip on how to implement this - I would put the layout of the three UIViews and text into a separate UIView subclass. Then, you can simply instantiate an instance of that UIView subclass and place it where you need in your layout like you would any other type of view or control.
Basically, by making your own subclasss, you create your own control that you were looking for originally.

UITableView for a list of Controls [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I am trying to understand when one should/should not use a UITableView.
I do know, if there is a table of information UITableView would be the perfect fit. But what if there are rows of "controls" ?
See the image below.
What are some of the advantages and disadvantages of using a UITableView to achieve layout above?
What alternatives to a UITableView exist for achieving such a layout?
This comes down to the question of how many controls/rows you will have and what they represent.
Dynamic Number of Controls Based on Model
A tableview is the perfect solution. The complications with having controls in a table view cell that is dynamically generated:
1) You cannot add IBActions for controls in table view cells. You will need to add a target/action to each control when the cell is generated.
2) Your action method will need a way to determine which element in your model the cell is displaying when selected (since cells are reused, controls will correspond to many model objects). To do this you need the index path in your model corresponding to the selected control. This can be done as follows (assuming a button but should work for any control):
Determine the control's position in the tableview:
let buttonPosition = button.convertPoint(.zero, toView: tableView)
Find the index path
let indexPath = self.indexPathForRowAtPoint(buttonPosition)
Then query your model for the object at the index path and respond accordingly.
Finite Number of Controls
The above is needlessly complex if you have a finite and known number of controls at runtime. In that case the above layout can be easily achieved with a UIStackView.
See StackView Documentation
Having controls in tableViews is perfectly fine.
You may want to know that tableviews have scrollable content and selectable cells, so your interactions will be slightly different than if you directly put your controls in a view.
Row selection and bouncing bounds can be annoying, as well as the delayed tap while touching inside a scroll view.
But if you need your controls to be dynamically shown depending on your settings, it can be done with the tableview data source or delegate methods.

Resources