/// <summary> /// Called by the TableView to get the actual UITableViewCell to render for the particular section and row /// </summary> public override UITableViewCell GetCell(UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath) { //---- declare vars UITableViewCell cell = tableView.DequeueReusableCell(this._cellIdentifier); //---- if there are no cells to reuse, create a new one if (cell == null) { cell = new UITableViewCell(UITableViewCellStyle.Default, this._cellIdentifier); } //---- create a shortcut to our item BasicTableViewItem item = this._tableItems[indexPath.Section].Items[indexPath.Row]; cell.TextLabel.Text = item.Movie.title; if (!string.IsNullOrEmpty(item.Movie.thumbNail)) { MonoTouch.Foundation.NSUrl nsUrl = new MonoTouch.Foundation.NSUrl(item.Movie.thumbNail); MonoTouch.Foundation.NSData data = MonoTouch.Foundation.NSData.FromUrl(nsUrl); var myImage = new UIImage(data); cell.ImageView.Image = myImage; } return(cell); }
public override void RowSelected(UITableView tableView, NSIndexPath indexPath) { BasicTableViewItem item = this._tableItems[indexPath.Section].Items[indexPath.Row]; Movie movie = item.Movie; new UIAlertView("Row Selected", movie.title, null, "OK", null).Show(); tableView.DeselectRow(indexPath, true); // iOS convention is to remove the highlight }
public override void RowSelected(UITableView tableView, NSIndexPath indexPath) { BasicTableViewItem item = this._tableItems[indexPath.Section].Items[indexPath.Row]; Movie movie = item.Movie; //Launch the Individual Movie Screen with the selected movie IndividualMovieView movieScreen = new IndividualMovieView(movie); AppDelegate.rootNavigationController.PushViewController(movieScreen, true); tableView.DeselectRow(indexPath, true); // iOS convention is to remove the highlight }
/// <summary> /// Called by the TableView to get the actual UITableViewCell to render for the particular section and row /// </summary> public override UITableViewCell GetCell(UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath) { //---- declare vars UITableViewCell cell = tableView.DequeueReusableCell(this._customCellIdentifier); CustomCell customCellController = null; //---- if there are no cells to reuse, create a new one if (cell == null) { customCellController = new CustomCell(); // retreive the cell from our custom cell controller cell = customCellController.Cell; // give the cell a unique ID, so we can match it up to the controller cell.Tag = Environment.TickCount; // store our controller with the unique ID we gave our cell this._cellControllers.Add(cell.Tag, customCellController); } else { // retreive our controller via it's unique ID customCellController = this._cellControllers[cell.Tag]; } //---- create a shortcut to our item BasicTableViewItem item = this._tableItems[indexPath.Section].Items[indexPath.Row]; //---- set our cell properties customCellController._CriticScore = item.Movie.CriticScore; customCellController._Title = item.Movie.Title; customCellController._Indicator = item.Movie.FanIndicator; customCellController._Mpaa = item.Movie.MPAA; customCellController._RunTime = item.Movie.RunTime; customCellController._Actors = item.Movie.AbridgedActors; if (!string.IsNullOrEmpty(item.Movie.ThumbNail)) { MonoTouch.Foundation.NSUrl nsUrl = new MonoTouch.Foundation.NSUrl(item.Movie.ThumbNail); MonoTouch.Foundation.NSData data = MonoTouch.Foundation.NSData.FromUrl(nsUrl); var myImage = new UIImage(data); customCellController._Thumbnail.Image = myImage; } return(cell); }