[MonoTouch] SDK 5 issue

Sergio Fadda sergio.fadda at logobject.ch
Tue Oct 18 03:14:47 EDT 2011


Thank you very much,
actually I solved the problem moving only the controllers in AppDelegate 
and MyController (that is, _navCtrl and menuCtrl): since references of 
views, toolbar, etc. are retained by the controllers the GC should not 
remove them when the scopes terminate.

Thank you again!

Il 17/10/2011 17:06, Nic Wise ha scritto:
> ignore the bit about __mt_window :) I thought you were using a XIB and
> a partial class, which does this for you. (ie, how the default
> template does it)
>
> On Mon, Oct 17, 2011 at 16:06, Nic Wise<nicw at fastchicken.co.nz>  wrote:
>> Try moving all the declarations out of FinishedLaunching, eg:
>>
>>
>>>                private MonoTouch.UIKit.UIWindow __mt_window;
>>>                private UITextField _txtField;
>>>
>>>>>>>> THEY should be here!
>>       MyController ctrl1;
>>       UIView mainView;
>>       UIToolbar toolbar;
>>
>>
>>
>>>                public override bool FinishedLaunching (UIApplication app, NSDictionary
>>> options)
>>>                {
>>>                        __mt_window = new UIWindow(UIScreen.MainScreen.Bounds);
>>>                        __mt_window.BackgroundColor = UIColor.White;
>>>
>> why are you using __mt_window? use the window property, which talks to
>>
>>>                        MyController ctrl1 = new MyController();
>>>
>>>                        UIView mainView = new UIView(UIScreen.MainScreen.Bounds);
>>>
>>>>>> NOT HERE!
>>
>>>                        UIToolbar toolbar = new UIToolbar(new RectangleF(0, 0, 320, 30));
>>>                        toolbar.Items = new[]
>>>                        {
>>>                                new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace),
>>>                                new UIBarButtonItem(UIBarButtonSystemItem.Done, HandleDoneButton)
>>>                        };
>>>
>>>>>> OR HERE - move UIToolbar out into a class-level variable
>>
>>
>>> Native stacktrace:
>>>
>>>        0   MTFailure                           0x000d5c18
>>> mono_handle_native_sigsegv + 408
>> SIGSEGV is a Signal for a Segment Violation.
>>
>> AKA a Null Pointer Exception.
>>
>> All those things above will be getting GC'ed before you get to use
>> them. The GC in the newer version of MT is (I beleive) a LOT more
>> agressive, so things going out of scope get cleaned up quickly.
>> Putting them in as class var's stops that.
>>
>>
>>
>> N
>>
>> --
>> Nic Wise
>> t.  +44 7788 592 806 | @fastchicken | http://www.linkedin.com/in/nicwise
>> b. http://www.fastchicken.co.nz/
>>
>> Nearest Bus: find when the next bus is coming to your stop. http://goo.gl/Vcz1p
>> mobileAgent (for FreeAgent): get your accounts in your pocket.
>> http://goo.gl/IuBU
>> Trip Wallet: Keep track of your budget on the go: http://goo.gl/ePhKa
>> London Bike App: Find the nearest Boris Bike, and get riding! http://goo.gl/Icp2
>>
>
>


-- 
------------------------------------------------------------------------

Ai sensi del Codice in materia di protezione dei dati personali (d.L.vo 
196/03 e successive modifiche ed integrazioni), il contenuto di questa 
email e degli eventuali allegati sono riservati e ad uso esclusivo del 
destinatario. Chiunque riceva questo messaggio per errore è pregato di 
distruggerlo e di contattare il mittente. Si informa inoltre che la 
risposta alla presente compresi eventuali allegati potrebbero essere 
visionati, ai fini del disbrigo delle competenze lavorative, anche da 
altro personale addetto.

This email and any files transmitted with it are confidential and solely 
for the use of the intended recipient. If you have received this email 
in error, please notify us immediately by email and permanently delete 
the email without reading, copying or disclosing its contents to any 
other person.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/monotouch/attachments/20111018/847f71e1/attachment.html 


More information about the MonoTouch mailing list