Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
Note: Because the refresh control is specifically designed for use in a table view that's managed by a table view controller, using it in a different context can result in undefined behavior.
- (void)_setRefreshControl:(UIRefreshControl *)obj;
[Register ("MyViewController")]
partial class MyViewController
{
[Outlet]
public UITableView myTableView { get; set; }
// ...
}
public partial class MyViewController : UIViewController
{
public UIRefreshControl myRefreshControl { get; set; }
public override void ViewDidLoad()
{
base.ViewDidLoad();
// ...
this.myRefreshControl = new UIRefreshControl();
this.myRefreshControl.AttributedTitle = new NSAttributedString("Обновляем...");
this.myRefreshControl.AddTarget(this, new ObjCRuntime.Selector("RefreshSource"), UIControlEvent.ValueChanged);
#region Fix the Jump problem
UITableViewController tableViewController = new UITableViewController();
tableViewController.TableView = this.myTableView;
tableViewController.RefreshControl = this.myRefreshControl;
#endregion
#region Fix the unwanted first showing
this.myRefreshControl.BeginRefreshing();
this.myRefreshControl.EndRefreshing();
#endregion
// ...
}
[Export("RefreshSource")]
private async void RefreshSource()
{
#region Edit source data
await Task.Run(() =>
{
Thread.Sleep(3000);
});
#endregion
this.myTableView.ReloadData();
this.myRefreshControl.EndRefreshing();
}
}
let cell: UITableViewCell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: "MyTestSwiftCell")
cell.text = "\(text) \(indexPath.row)"
cell.detailTextLabel.text = "Hi, \(indexPath.row)"
cell.detailTextLabel.textColor = UIColor.purpleColor()
return cell
var tableViewCell = tableView.dequeueReusableCellWithIdentifier(CellReuseId) as? UITableViewCell;
if (!tableViewCell){
tableViewCell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: CellReuseId);
tableViewCell.detailTextLabel.textColor = UIColor.purpleColor()
}
tableViewCell.text = "\(text) \(indexPath.row)"
tableViewCell.detailTextLabel.text = "Hi, \(indexPath.row)"
return tableViewCell;
let CellReuseId = "Row";
var cell = tableView.dequeueReusableCellWithIdentifier("MyTestSwiftCell") as UITableViewCell
if (cell == nil){
cell.detailTextLabel.textColor = UIColor.purpleColor()
cell.text = "\(text) \(indexPath.row)"
cell.detailTextLabel.text = "Hi, \(indexPath.row)"
}
return cellif ( cell.detailTextLabel.text == "Subtitle" ) if ( cell.imageView.image == nil ) var tableViewCell = tableView.dequeueReusableCellWithIdentifier(CellReuseId) as? UITableViewCell;
tableViewCell!.detailTextLabel.textColor = UIColor.purpleColor()
tableViewCell!.text = "\(text) \(indexPath.row)"
tableViewCell!.detailTextLabel.text = "Hi, \(indexPath.row)"
return tableViewCell;
var tableViewCell = tableView.dequeueReusableCellWithIdentifier(CellReuseId) as UITableViewCell
tableViewCell.detailTextLabel.textColor = UIColor.purpleColor()
tableViewCell.text = "\(text) \(indexPath.row)"
tableViewCell.detailTextLabel.text = "Hi, \(indexPath.row)"
return tableViewCell
Реализуем pull to refresh и infinite scrolling на Swift