Example #1
0
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);
            AVAudioSession audioSession = AVAudioSession.SharedInstance();

            audioSession.Init();
            //audioSession.Category = AVAudioSession.CategoryPlayback;
            audioSession.SetActive(true, new NSError());
            //MonoTouch.AudioToolbox.AudioSession.Initialize ();

            WebLoadingSpinner.StopAnimating();
            NavigationItem.HidesBackButton = true;
            WebTitle.Text = _title;

            WebView.ScalesPageToFit = true;

            switch (_title)
            {
            case "Website":
                _url = _game.game_url;
                LoadWebUrl(_game.game_url);
                break;

            case "Trailer":
                _url = _game.trailer_url;
                LoadWebUrl(_game.trailer_url);
                break;

            case "Order":
                if (_game.order_links.Count == 1)
                {
                    _url = _game.order_links[0].order_url;
                    LoadWebUrl(_url);
                }
                else
                {
                    actionSheet = new UIActionSheet("Choose a platform");
                    foreach (var link in _game.order_links)
                    {
                        actionSheet.AddButton(link.platform);
                    }

                    actionSheet.AddButton("Cancel");
                    actionSheet.CancelButtonIndex = _game.order_links.Count;
                    actionSheet.ShowInView(ParentViewController.View);

                    actionSheet.Clicked += delegate(object a, UIButtonEventArgs b) {
                        if (b.ButtonIndex == actionSheet.CancelButtonIndex)
                        {
                            this.DismissViewController(true, null);
                            this.NavigationController.PopViewControllerAnimated(true);
                        }
                        else
                        {
                            _url = _game.order_links[b.ButtonIndex].order_url;
                            LoadWebUrl(_url);
                        }
                    };
                }
                break;
            }
        }