0

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)?

jon smith
  • 73
  • 1
  • 6

1 Answers1

0

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 First UITableView sample row

Add another UITableView to create the side listing, with just an alphabet as cell. Something like Second UITableView layout

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:

  1. Drag and drop two UITableViews in StoryBoard, place and resize them however you want (according to the layout you want), apply constraints.
  2. Give each StoryBoard a reference like you do for other elements such as buttons etc. or give them a Tag.
  3. 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 :)

Singhal2
  • 450
  • 7
  • 22
  • This is very helpful but can tou tell me how to have more then one tableviews in a single view controller? – jon smith Jul 27 '17 at 11:26
  • Firstly I need to know, are you using a storyboard or not? Also, are you using Xamarin Studio with Xcode or Visual Studio? Either way a TableView is just like any other element, you can have as many as you want. Give a reference to each and assign Data-source and Delegate like you do normally, but for each one separately. Am I making sense? – Singhal2 Jul 27 '17 at 11:43
  • I am using storyboards because I think it will be easier to make custom cells with them, and i am using VS. so i should just drag table views from the toolbox? And if so how can I modify the appearance of the index one and how do I make sure it stays in the same position(constraints maybe?). – jon smith Jul 27 '17 at 12:16
  • I updated the answer :) – Singhal2 Jul 27 '17 at 12:26
  • Thank you for the help, it is really appreciated. – jon smith Jul 27 '17 at 12:44
  • I understood everything you wrote but I was wondering if you could maybe tell me how to move the table view to desired section once a letter has been pressed(I know how to tell which section I need to jump to but I dont know how). – jon smith Jul 28 '17 at 09:33
  • https://developer.xamarin.com/api/member/MonoTouch.UIKit.UITableView.ScrollToRow/ – Singhal2 Jul 28 '17 at 10:08
  • https://stackoverflow.com/a/5856525/2974780 – Singhal2 Jul 28 '17 at 10:09