不明白运行时错误

时间:2012-11-02 14:14:34

标签: uiscrollview xamarin.ios

有一个难以理解的问题。我在viewcontroller中有一个ShinobiGrid视图。 尝试使用

将网格置于网格(列)的中间位置
spreadSheet.SetContentOffset(new PointF(200, 0), true);

通过这样做我得到一个运行时异常,我不理解它(因为我不是Objective-C程序员)。 发生了什么事?

{MonoTouch.Foundation.MonoTouchException: Objective-C exception thrown.  
Name:       NSRangeException Reason: *** -[__NSArrayM insertObject:atIndex:]: 
index 1 beyond bounds for empty array   at (wrapper managed-to-native)     
MonoTouch.ObjCRuntime.Messaging:void_objc_msgSendSuper_PointF_bool 
(intptr,intptr,System.Drawing.PointF,bool)   at 
MonoTouch.UIKit.UIScrollView.SetContentOffset   
(PointF contentOffset, Boolean animated) [0x00027] in 
/Developer/MonoTouch/Source/monotouch/src/UIKit/UIScrollView.g.cs:210    at 
Roombler.Gui.IPad.ViewControllers.RoomblerViewController.ViewDidLoad () [0x0011c] in 
/Users/jonas/Documents/Roombler/BitBucket/Roombler.Gui/Roombler.Gui.IPad/ViewControllers/RoomblerViewController.cs:97    
at (wrapper managed-to-native) MonoTouch.ObjCRuntime.Messaging:void_objc_msgSend  
(intptr,intptr)   at MonoTouch.UIKit.UIWindow.MakeKeyAndVisible () [0x00010] in 
/Developer/MonoTouch/Source/monotouch/src/UIKit/UIWindow.g.cs:124    at 
Roombler.Gui.IPad.ViewControllers.AppDelegate.FinishedLaunching 

(MonoTouch.UIKit.UIApplication app, MonoTouch.Foundation.NSDictionary options) 
[0x00031] in
/Users/jonas/Documents/Roombler/BitBucket/Roombler.Gui/Roombler.Gui.IPad/ViewControllers/AppDelegate.cs:29    
at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain 
(int,string[],intptr,intptr)   at MonoTouch.UIKit.UIApplication.Main (System.String[] 
args, System.String principalClassName, System.String delegateClassName) [0x0004c] in 
/Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38    at 
Roombler.Gui.IPad.Application.Main (System.String[] args) [0x00000] in 
/Users/jonas/Documents/Roombler/BitBucket/Roombler.Gui/Roombler.Gui.IPad/Main.cs:17 }

1 个答案:

答案 0 :(得分:0)

ShinobiControll的支持团队帮助了我。

“网格不知道那时有多大。你可以把

spreadSheet.Reload();

在SetContentOffset之前

这就是诀窍!