 |
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

November 26th, 2010, 09:27 AM
|
|
Registered User
|
|
Join Date: Nov 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

November 26th, 2010, 10:47 PM
|
|
Registered User
|
|
Join Date: Nov 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
Originally Posted by Tom Kamphuis
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
|
|

November 29th, 2010, 03:09 AM
|
|
Registered User
|
|
Join Date: Nov 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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?).
|
|

November 29th, 2010, 08:11 PM
|
|
Registered User
|
|
Join Date: Nov 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
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 09:41 AM |
| Chapter 10 |
czambran |
BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 |
2 |
March 29th, 2005 09:35 AM |
| Cr8 & Stored procedure ..Crash ..Crash |
swissaKM |
Crystal Reports |
0 |
January 2nd, 2005 06:02 AM |
|
 |
|