-
Notifications
You must be signed in to change notification settings - Fork 204
/
TableSourceCollection.cs
66 lines (56 loc) · 1.82 KB
/
TableSourceCollection.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#region Copyright Syncfusion Inc. 2001-2024.
// Copyright Syncfusion Inc. 2001-2024. All rights reserved.
// Use of this code is subject to the terms of our license.
// A copy of the current license can be obtained at any time by e-mailing
// [email protected]. Any infringement will be prosecuted under
// applicable laws.
#endregion
using System;
using Foundation;
using UIKit;
namespace SampleBrowser
{
public class TableSourceCollection : UITableViewSource
{
protected string[] tableItems;
protected string cellIdentifier = "TableCell";
//HomeScreen owner;
public TableSourceCollection(string[] items)
{
tableItems = items;
//this.owner = owner;
}
public override nint NumberOfSections(UITableView tableView)
{
return 1;
}
public override nint RowsInSection(UITableView tableview, nint section)
{
return tableItems.Length;
}
public override nfloat GetHeightForRow(UITableView tableView, NSIndexPath indexPath)
{
if ((UIDevice.CurrentDevice).UserInterfaceIdiom == UIUserInterfaceIdiom.Phone)
return 16;
else
return 32;
}
/// <summary>
/// Called by the TableView to get the actual UITableViewCell to render for the particular row
/// </summary>
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
{
UITableViewCell cell = tableView.DequeueReusableCell(cellIdentifier);
string item = tableItems[indexPath.Row];
//---- if there are no cells to reuse, create a new one
if (cell == null)
{ cell = new UITableViewCell(UITableViewCellStyle.Default, cellIdentifier); }
if ((UIDevice.CurrentDevice).UserInterfaceIdiom == UIUserInterfaceIdiom.Phone)
cell.TextLabel.Font = UIFont.FromName("Helvetica", 12f);
else
cell.TextLabel.Font = UIFont.FromName("Helvetica", 18f);
cell.TextLabel.Text = item;
return cell;
}
}
}