Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Mobile Development > BOOK: Professional iPhone Programming with MonoTouch and .NET/C#
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional iPhone Programming with MonoTouch and .NET/C#
This is the forum to discuss the Wrox book Professional iPhone Programming with MonoTouch and .NET/C# by Wallace B. McClure, Rory Blyth, Craig Dunn, Chris Hardy, Martin Bowling ; ISBN: 978-0-470-63782-1
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional iPhone Programming with MonoTouch and .NET/C# section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old November 26th, 2010, 08:27 AM
Registered User
 
Join Date: Nov 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 10: UIImagePickerControl photolibrary crash

Hi,

I'm new to iPhone development and the help I'm getting through this book helps me a lot. I'm trying to build an application similar to the photo picker/camera as explained in chapter 10 (example 10-5). In order to learn best practices I've used code from the examples to make it work, but the given example doesn't even work when I use the code from the download. When I run the demo application the first time, I get two warnings as soon as I press the "Select Image" button about "Using two-stage rotation animation".
These are warnings, the application just works and shows me the photo album library. But when I click one of these albums, I get a SIGSEGV error and the applications stops running. At the bottom of the console window I get the "Object reference not set to an instance of..." error, and the args array in the Main method is empty.

What's wrong with the example/code? Or is it some version issue? Thanks for the help!

Tom
Reply With Quote
  #2 (permalink)  
Old November 26th, 2010, 09:47 PM
Registered User
 
Join Date: Nov 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Tom Kamphuis View Post
Hi,

I'm new to iPhone development and the help I'm getting through this book helps me a lot. I'm trying to build an application similar to the photo picker/camera as explained in chapter 10 (example 10-5). In order to learn best practices I've used code from the examples to make it work, but the given example doesn't even work when I use the code from the download. When I run the demo application the first time, I get two warnings as soon as I press the "Select Image" button about "Using two-stage rotation animation".
These are warnings, the application just works and shows me the photo album library. But when I click one of these albums, I get a SIGSEGV error and the applications stops running. At the bottom of the console window I get the "Object reference not set to an instance of..." error, and the args array in the Main method is empty.

What's wrong with the example/code? Or is it some version issue? Thanks for the help!

Tom
Hi Tom,

Since the publishing of the book, the garbage collection of MonoTouch has greatly improved. This unfortunately meant that some of the samples would throw issues like this. The problem is that the UIImagePickerController is getting GC'd whilst the picker is being displayed so when an image is selected, it will crash.

To sort this issue out, all you need to do is move the UIImagePickerController to the class level and use it from there, see the following gist... https://gist.github.com/717504
or the code example below.
Code:
 
                UIImagePickerController picker;
		
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();
			
			UIButton button = UIButton.FromType(UIButtonType.RoundedRect);
			button.Frame = new RectangleF(0f, 30f, 320, 40f);
			button.SetTitle("Select Image", UIControlState.Normal);
			button.TouchUpInside += delegate(object sender, EventArgs e) {
			picker = new UIImagePickerController();
				picker.Delegate = new MyImagePickerDelegate(this);
				this.PresentModalViewController(picker, true);
			};
			this.View.AddSubview(button);

		}
Hope this helps,

ChrisNTR
Reply With Quote
  #3 (permalink)  
Old November 29th, 2010, 02:09 AM
Registered User
 
Join Date: Nov 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Chris, that helped a lot. One thing still raises a warning; the using of two-stage rotation animation. Are these warnings showstoppers in distributing an app or should it be resolved (and when it should be resolved: how?).
Reply With Quote
  #4 (permalink)  
Old November 29th, 2010, 07:11 PM
Registered User
 
Join Date: Nov 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Weird, I'm not seeing that warning on my side, try reading through here and see if that helps - http://stackoverflow.com/questions/2...ckercontroller

Cheers,

ChrisNTR
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 10, listing 10-10-app kiwibrit BOOK: Professional ASP.NET 3.5 : in C# and VB ISBN: 978-0-470-18757-9 2 August 18th, 2009 04:21 AM
Chapter 10 JimSchubert BOOK: Ruby on Rails for Microsoft Developers 1 May 17th, 2009 11:35 PM
Chapter 10 gogeo BOOK: Beginning Access 2003 VBA 1 January 22nd, 2006 08:41 AM
Chapter 10 czambran BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 2 March 29th, 2005 08:35 AM
Cr8 & Stored procedure ..Crash ..Crash swissaKM Crystal Reports 0 January 2nd, 2005 05:02 AM



All times are GMT -4. The time now is 07:03 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.