/// <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;
        }
Esempio n. 2
0
        /// <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);
        }