Bug 9937 - Setting MPVolumeView images
Summary: Setting MPVolumeView images
Status: RESOLVED INVALID
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: 6.0.x
Hardware: Other Other
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2013-01-31 06:37 UTC by Alexander
Modified: 2013-01-31 08:20 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED INVALID

Description Alexander 2013-01-31 06:37:15 UTC
MonoDevelop 3.1.1
Installation UUID: ee7dbcdf-5ad3-4078-b2cf-7f358daccd94
Runtime:
	Mono 2.10.9 (tarball)
	GTK 2.24.10
	GTK# (2.12.0.0)
	Package version: 210090011
Apple Developer Tools:
	 Xcode 4.5 (1839)
	 Build 4G182
Xamarin.Mac: Not Installed
Monotouch: 6.0.10
Mono for Android: Not Installed

Build information:
	Release ID: 30101000
	Git revision: 5d928ec4f9d5864b4db04a1301b8a8649b43fb9d
	Build date: 2012-12-14 19:11:30+0000
	Xamarin addins: 80f2dcc8fe4ed316b3e77dde496fc33d90305047
Operating System:
	Mac OS X 10.7.5
	Darwin Edgars-Mac-mini.local 11.4.2 Darwin Kernel Version 11.4.2
	    Thu Aug 23 16:25:48 PDT 2012
	    root:xnu-1699.32.7~1/RELEASE_X86_64 x86_64


Code:

    _volumeSlider = new MPVolumeView();
    _volumeSlider.SetMaximumVolumeSliderImage(Images.Get("Graphics/screen_player/progressbg.png", leftCapWidth:18), UIControlState.Normal);
    _volumeSlider.SetMinimumVolumeSliderImage(Images.Get("Graphics/screen_player/progressbar.png", leftCapWidth:18), UIControlState.Normal);
    _volumeSlider.SetVolumeThumbImage(Images.Get("Graphics/screen_player/progressctrl_volume.png"), UIControlState.Normal);
    _volumeSlider.SetVolumeThumbImage(Images.Get("Graphics/screen_player/progressctrl_volume_active.png"), UIControlState.Highlighted);
    _rotationView.Add(_volumeSlider);


Works fine on ios 6, but on iphone 3gs (ios 5.1.1 (9B206)) methods that change slider images my application crashes with:

2013-01-31 15:25:08.299 iPhone[995:707] -[MPVolumeView setVolumeThumbImage:forState:]: unrecognized selector sent to instance 0x35e8f30
2013-01-31 15:25:08.313 iPhone[995:707] #1 [MonoTouchException: UnhandledExceptions] Handle(ex) MonoTouch.Foundation.MonoTouchException: Objective-C exception thrown.  Name: NSInvalidArgumentException Reason: -[MPVolumeView setVolumeThumbImage:forState:]: unrecognized selector sent to instance 0x35e8f30
  at MonoTouch.MediaPlayer.MPVolumeView.SetVolumeThumbImage (MonoTouch.UIKit.UIImage image, UIControlState state) [0x00000] in <filename unknown>:0 
  at Touchin.Trava.UI.Controllers.PlayerController.ViewDidLoad () [0x00000] in <filename unknown>:0 
  at MonoTouch.UIKit.UIViewController.get_View () [0x00000] in <filename unknown>:0 
  at Touchin.Trava.UI.Controllers.PlayerController.InitWith (IEnumerable`1 tracks, Boolean clearTracklist) [0x00000] in <filename unknown>:0 
  at Touchin.Trava.UI.Controllers.PlayerController.InitWith (Touchin.Trava.Logic.ApiDataModel.CatalogApiData.Track track) [0x00000] in <filename unknown>:0 
  at Touchin.Trava.UI.Player.InitWith (Touchin.Trava.Logic.ApiDataModel.CatalogApiData.Track track) [0x00000] in <filename unknown>:0 
  at Touchin.Trava.UI.Controllers.AlbumController.OnCellClicked (MonoTouch.Foundation.NSIndexPath indexPath, Touchin.Trava.Logic.ApiDataModel.CatalogApiData.Track track) [0x00000] in <filename unknown>:0 
  at (wrapper delegate-invoke) <Module>:invoke_void__this___NSIndexPath_Track (MonoTouch.Foundation.NSIndexPath,Touchin.Trava.Logic.ApiDataModel.CatalogApiData.Track)
  at Touchin.Trava.UI.Sources.CustomSource`2[Touchin.Trava.Logic.ApiDataModel.CatalogApiData.Track,Touchin.Trava.UI.Controls.TrackCell].RowSelected (MonoTouch.UIKit.UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath) [0x00000] in <filename unknown>:0 
  at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00000] in <filename unknown>:0 
  at iPhone.Application.Main (System.String[] args) [0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: MonoTouch.Foundation.MonoTouchException: Objective-C exception thrown.  Name: NSInvalidArgumentException Reason: -[MPVolumeView setVolumeThumbImage:forState:]: unrecognized selector sent to instance 0x35e8f30
  at MonoTouch.MediaPlayer.MPVolumeView.SetVolumeThumbImage (MonoTouch.UIKit.UIImage image, UIControlState state) [0x00000] in <filename unknown>:0 
  at Touchin.Trava.UI.Controllers.PlayerController.ViewDidLoad () [0x00000] in <filename unknown>:0 
  at MonoTouch.UIKit.UIViewController.get_View () [0x00000] in <filename unknown>:0 
  at Touchin.Trava.UI.Controllers.PlayerController.InitWith (IEnumerable`1 tracks, Boolean clearTracklist) [0x00000] in <filename unknown>:0 
  at Touchin.Trava.UI.Controllers.PlayerController.InitWith (Touchin.Trava.Logic.ApiDataModel.CatalogApiData.Track track) [0x00000] in <filename unknown>:0 
  at Touchin.Trava.UI.Player.InitWith (Touchin.Trava.Logic.ApiDataModel.CatalogApiData.Track track) [0x00000] in <filename unknown>:0 
  at Touchin.Trava.UI.Controllers.AlbumController.OnCellClicked (MonoTouch.Foundation.NSIndexPath indexPath, Touchin.Trava.Logic.ApiDataModel.CatalogApiData.Track track) [0x00000] in <filename unknown>:0 
  at (wrapper delegate-invoke) <Module>:invoke_void__this___NSIndexPath_Track (MonoTouch.Foundation.NSIndexPath,Touchin.Trava.Logic.ApiDataModel.CatalogApiData.Track)
  at Touchin.Trava.UI.Sources.CustomSource`2[Touchin.Trava.Logic.ApiDataModel.CatalogApiData.Track,Touchin.Trava.UI.Controls.TrackCell].RowSelected (MonoTouch.UIKit.UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath) [0x00000] in <filename unknown>:0 
  at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00000] in <filename unknown>:0 
  at iPhone.Application.Main (System.String[] args) [0x00000] in <filename unknown>:0 
Stacktrace:


Native stacktrace:

	0   iPhone                              0x005a8c3d iPhone + 5930045
	1   iPhone                              0x005d6289 iPhone + 6115977
	2   libsystem_c.dylib                   0x351fe7ed _sigtramp + 48
	3   libsystem_c.dylib                   0x351f420f pthread_kill + 54
	4   libsystem_c.dylib                   0x351ed29f abort + 94
	5   iPhone                              0x005848a3 iPhone + 5781667
	6   iPhone                              0x00622130 monotouch_create_managed_ref + 1068
	7   iPhone                              0x005a6919 iPhone + 5921049
	8   iPhone                              0x0056ea37 iPhone + 5691959
	9   iPhone                              0x005a89bb iPhone + 5929403
	10  iPhone                              0x005a8a89 iPhone + 5929609
	11  iPhone                              0x005d5545 iPhone + 6112581
	12  iPhone                              0x00281d68 iPhone + 2624872
	13  iPhone                              0x0062217c monotouch_create_managed_ref + 1144
	14  iPhone                              0x00622208 monotouch_register_delegates + 0
	15  CoreFoundation                      0x3110f957 __handleUncaughtException + 74
	16  libobjc.A.dylib                     0x3744d345 _objc_terminate + 128
	17  libc++abi.dylib                     0x371ba3c5 _ZL19safe_handler_callerPFvvE + 76
	18  libc++abi.dylib                     0x371ba451 _ZdlPv + 0
	19  libc++abi.dylib                     0x371bb825 __cxa_current_exception_type + 0
	20  libobjc.A.dylib                     0x3744d2a9 objc_exception_rethrow + 12
	21  CoreFoundation                      0x3106550d CFRunLoopRunSpecific + 404
	22  CoreFoundation                      0x3106536d CFRunLoopRunInMode + 104
	23  GraphicsServices                    0x330df439 GSEventRunModal + 136
	24  UIKit                               0x307c8cd5 UIApplicationMain + 1080
	25  iPhone                              0x005352d4 iPhone + 5456596
	26  iPhone                              0x0045f490 iPhone + 4580496
	27  iPhone                              0x0024d488 iPhone + 2409608
	28  iPhone                              0x00570867 iPhone + 5699687
	29  iPhone                              0x005ccdd7 iPhone + 6077911
	30  iPhone                              0x005cf8bb iPhone + 6088891
	31  iPhone                              0x005d2b3f iPhone + 6101823
	32  iPhone                              0x00583b37 iPhone + 5778231
	33  iPhone                              0x006109a4 iPhone + 6355364
	34  iPhone                              0x00002028 iPhone + 4136

=================================================================
Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================
Comment 1 Rolf Bjarne Kvinge [MSFT] 2013-01-31 08:17:44 UTC
This is because SetVolumeThumbImage is only available in iOS 6: http://developer.apple.com/library/ios/#documentation/mediaplayer/reference/MPVolumeView_Class/Reference/Reference.html#//apple_ref/occ/instm/MPVolumeView/setVolumeThumbImage:forState:

You must check the iOS version you're executing on before calling this method. You can do this by checking t
Comment 2 Rolf Bjarne Kvinge [MSFT] 2013-01-31 08:18:39 UTC
You can do this by calling UIDevice.CurrentDevice.CheckSystemVersion (here is an example: http://stackoverflow.com/a/8311516/183422).
Comment 3 Rolf Bjarne Kvinge [MSFT] 2013-01-31 08:20:08 UTC
Closing, this is not a bug in MonoTouch.