I'm building a Xamarin.iOS app, I have a UITableView with a custom UITableViewCell, when I add data from server to the table or if I begin to scroll up and down fast, the app crashes and give me this error log:
Native stacktrace:
>0 CardReader_iOS 0x003b5ed5 mono_handle_native_sigsegv + 260
>1 CardReader_iOS 0x003befad mono_sigsegv_signal_handler + 176
>2 libsystem_platform.dylib 0x3a600063 _sigtramp + 42
>3 CardReader_iOS 0x000d0798
CardReader_iOS_ICTableContactSource_GetCell_MonoTouch_UIKit_UITableView_MonoTouch_Foundation_NSIndexPath + 164
>4 CardReader_iOS 0x002740d0
wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 200
>5 CardReader_iOS 0x003c1087 mono_jit_runtime_invoke + 1134
>6 CardReader_iOS 0x003fbd2d mono_runtime_invoke + 88
>7 CardReader_iOS 0x003914af
native_to_managed_trampoline_CardReader_iOS_ICTableContactSource_GetCell + 402
8 UIKit 0x3256da5b + 410
>9 UIKit 0x32515e7d <redacted> + 1804
>10 UIKit 0x32515699 <redacted> + 184
>11 UIKit 0x3243bda3 <redacted> + 346
>12 QuartzCore 0x320c2c6b <redacted> + 142
>13 QuartzCore 0x320be47b <redacted> + 350
>14 QuartzCore 0x320be30d <redacted> + 16
>15 QuartzCore 0x320bdd1f <redacted> + 230
>16 QuartzCore 0x320bdb2f <redacted> + 314
>17 QuartzCore 0x32112825 <redacted> + 516
>18 IOMobileFramebuffer 0x34d0876d <redacted> + 104
>19 IOKit 0x309aaa75 IODispatchCalloutFromCFMessage + 248
>20 CoreFoundation 0x2fc88e21 <redacted> + 136
>21 CoreFoundation 0x2fc939df <redacted> + 34
>22 CoreFoundation 0x2fc9397b <redacted> + 346
>23 CoreFoundation 0x2fc9214f <redacted> + 1398
>24 CoreFoundation 0x2fbfcc27 CFRunLoopRunSpecific + 522
>25 CoreFoundation 0x2fbfca0b CFRunLoopRunInMode + 106
>26 GraphicsServices 0x348ec283 GSEventRunModal + 138
>27 UIKit 0x324a0049 UIApplicationMain + 1136
>28 CardReader_iOS 0x00166e40
wrapper_managed_to_native_MonoTouch_UIKit_UIApplication_UIApplicationMain_int_string___intptr_intptr + 272
29 CardReader_iOS 0x00143244 MonoTouch_UIKit_UIApplication_Main_string___string_string + 300
>30 CardReader_iOS 0x000aa148 CardReader_iOS_Application_Main_string__ + 172
>31 CardReader_iOS 0x002740d0
wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr + 200
>32 CardReader_iOS 0x003c1087 mono_jit_runtime_invoke + 1134
>33 CardReader_iOS 0x003fbd2d mono_runtime_invoke + 88
>34 CardReader_iOS 0x003ff8b5 mono_runtime_exec_main + 276
>35 CardReader_iOS 0x003ff705 mono_runtime_run_main + 424
>36 CardReader_iOS 0x003af6e1 mono_jit_exec + 48
>37 CardReader_iOS 0x00432704 main + 2468
>38 libdyld.dylib 0x3a4e5ab7 <redacted> + 2
> Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
Here Is My Code:
This method execute after server callback I fill data from server into a new List
public void addContacts(){
InvokeOnMainThread (delegate {
try{
tableContact.BeginUpdates();
items.AddRange(itemsAdd);
ICGlobal.contacts.AddRange(itemsAdd);
tableContact.ReloadData();
tableContact.SetNeedsDisplay();
tableContact.EndUpdates();
}catch(Exception e){
Console.WriteLine(e.StackTrace);
}
ICLayoutMgr.Get().SetBusy(false);
tableContact.ScrollEnabled = true;
});
}
this is the Custom cell class
public class ICTableContactCell : UITableViewCell
{
ICContactTableItem item;
ICContactCellView viewData;
public ICTableContactCell (ICContactTableItem item,NSString cellId) : base(UITableViewCellStyle.Default, cellId )
{
ContentView.BackgroundColor = UIColor.White;
this.item = item;
viewData = new ICContactCellView (this.item);
var view = new UIView (ContentView.Frame);
view.BackgroundColor = UIColor.Gray;
this.SelectionStyle = UITableViewCellSelectionStyle.Default;
this.SelectedBackgroundView = view;
ContentView.Add (viewData);
}
public override void LayoutSubviews ()
{
base.LayoutSubviews ();
viewData.Frame = ContentView.Bounds;
viewData.SetNeedsDisplay ();
}
public void UpdateCell (ICContactTableItem titem){
this.item = titem;
viewData.UpdateCell (titem);
}
}
public class ICContactCellView:UIView{
UILabel uiTitle;
UILabel uiCompany;
UIImageView imgSelected;
UIImageView imgDetail;
ICContactTableItem item;
static UIImage arrow=UIImage.FromFile("btnArrow.png");
static UIImage address=UIImage.FromFile("btnaddress.png");
public ICContactCellView (ICContactTableItem item)
{
this.item = item;
BackgroundColor = UIColor.White;
float yOffset = 5f;
UIColor otherColor = UIColor.Black;
uiTitle = IOTM.GUI.CreateLabel ("TITLE", yOffset+10f, yOffset, 200f, 24f, otherColor, "Helvetica-Bold", 14f);
uiCompany = IOTM.GUI.CreateLabel ("Comapany", yOffset+10f, yOffset + 16f, 200f, 24f, otherColor, "HelveticaNeue", 13f);
imgSelected =new UIImageView(){
Image = address,
Frame = IOTM.GUI.CreateFrame( yOffset+235f, yOffset+5f, 30, 30)
};
imgDetail = new UIImageView () {
Image = arrow,
Frame = IOTM.GUI.CreateFrame (280f, yOffset + 15f, 10, 10)
};
Add (uiTitle);
Add (uiCompany);
Add (imgSelected);
Add (imgDetail);
UpdateCell (this.item);
}
public void UpdateCell (ICContactTableItem titem){
this.item = titem;
if (item.index % 2 == 0)
BackgroundColor = ICGlobal.Gray;
else {
BackgroundColor = UIColor.White;
}
uiCompany.Text = "Company: " + item.enterprise;
uiTitle.Text = item.firstName+" "+item.lastName;
SetNeedsDisplay ();
}
}
TableViewSource
public class ICTableContactSource : UITableViewSource
{
public ICTableContactCell cell;
private static ICLoadMoreCell loadMore;
private ICContactTableItem itemC;
protected List<ICContactTableItem> tableItems;
protected string cellIdentifier;
public UINavigationController ParentNavigation{ get; set; }
public ICTableContactSource(List<ICContactTableItem> tl)
{
cellIdentifier = "contactCellID";
tableItems = tl;
}
public override int RowsInSection(UITableView t, int i)
{
return tableItems.Count+1;
}
public override UITableViewCell GetCell (UITableView tableView, NSIndexPath indexPath)
{
if (indexPath.Row == tableItems.Count) {
loadMore = tableView.DequeueReusableCell ("LoadingCell") as ICLoadMoreCell;
if (loadMore == null) {
loadMore = new ICLoadMoreCell (new NSString ("LoadingCell"));
}
loadMore.UpdateCell (null, 0);
return loadMore;
} else {
cell = tableView.DequeueReusableCell (cellIdentifier) as ICTableContactCell;
itemC = tableItems [indexPath.Row];
if (cell == null) {
itemC.index = indexPath.Row;
cell = new ICTableContactCell (itemC, new NSString (cellIdentifier));
cell.UpdateCell (itemC);
} else {
itemC.index = indexPath.Row;
cell.UpdateCell (itemC);
}
}
return cell as UITableViewCell;
}
public override void WillDisplay (UITableView tableView, UITableViewCell cell, NSIndexPath indexPath)
{
if (cell is ICLoadMoreCell) {
ICGlobal.currentContactView.loadMore ();
}
}
Related
I am getting a crash reported in crashlytics about partial apply in closure. I have tried other answers that mainly focus on using [weak self] but that didn't help. However, i am not getting a crash on my device.
According to the report the crash is somewhere in the function where i show my dropDown here is the code
func showDropDown(_ names: [String], forResult result: SearchPatientResultResponnse) {
guard let vc = viewController
else { return }
self.searchedPatientNames = result.data?.patientSearchSuggestions
Helpers.showSearchDropdown(anchorView: vc.searchBar.searchTextField, dataSource: names, scrollToTop: true, completion: { [weak self] (i, item) in
guard let self = self else {
return
}
vc.searchBar.text = item
vc.dismissKeyboard()
self.selectedSearchPatient = self.searchedPatientNames?[i]
if let d = self.searchedPatientNames?[i].dob {
vc.dobTF.text = DateTimeFormatters.userUIDateFormatterInUTC.string(from: d)
}
self.search(self.selectedSearchFilter)
}, fetchPaginationData: { [weak self] in
guard let self = self, !self.isNameSearchLastPage, self.page != -1 else {
return
}
vc.searchBar.isLoadingWithoutSearchIcon = true
self.fetchPatientNameNextPage()
}, cancel: { [weak self] in
self?.resetPaginationParams()
})
}
This is the function from where i am calling this showDropDown function
func getQueryPatientResponse() {
guard let vc = viewController else {
return
}
SocketIOManager.shared.queryResponseForPatient = { [weak self] result in
var names: [String] = []
self?.isNameSearchLastPage = result.data?.isLastPage ?? true
self?.page = result.data?.pageNumber ?? -1
for data in result.data?.patientSearchSuggestions ?? [] {
var name = ""
if !data.middleName.isEmpty {
name = data.firstName + " " + data.middleName + " " + data.lastName
} else {
name = data.firstName + " " + (data.lastName)
}
names.append(name)
}
vc.searchBar.isLoadingWithoutSearchIcon = false
self?.page == 1 ? self?.showDropDown(names, forResult: result) : self?.updateDropDown(names, forResult: result)
}
}
This is the crash report from crashlytics:-
Crashed: com.apple.main-thread
0 Ovada CM - PT 0x639b0 closure #1 in VisitStatusViewModel.showDropDown(_:forResult:)
+ 4340890032 (<compiler-generated>:4340890032)
1 Ovada CM - PT 0x3f328 partial apply for closure #1 in static Helpers.showSearchDropdown(anchorView:dataSource:scrollToTop:completion:fetchPaginationData:cancel:)
+ 121 (Helpers.swift:121)
2 Ovada CM - PT 0x15604c DropDown.tableView(_:didSelectRowAt:)
+ 4341882956 (<compiler-generated>:4341882956)
3 Ovada CM - PT 0x156548 #objc DropDown.tableView(_:didSelectRowAt:)
+ 4341884232 (<compiler-generated>:4341884232)
4 UIKitCore 0xfe36d0 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:isCellMultiSelect:deselectPrevious:]
+ 1640
5 UIKitCore 0xfe3050 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:]
+ 112
6 UIKitCore 0xfe394c -[UITableView _userSelectRowAtPendingSelectionIndexPath:]
+ 316
7 UIKitCore 0x30c240 -[_UIAfterCACommitBlock run] + 64
8 UIKitCore 0x227770 -[_UIAfterCACommitQueue flush] + 200
9 UIKitCore 0x155eb0 _runAfterCACommitDeferredBlocks + 640
10 UIKitCore 0x15657c _cleanUpAfterCAFlushAndRunDeferredBlocks + 128
11 UIKitCore 0x156748 _afterCACommitHandler + 56
12 CoreFoundation 0x3e83c _CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION_ + 32
13 CoreFoundation 0xfa74 __CFRunLoopDoObservers + 616
14 CoreFoundation 0xaffc __CFRunLoopRun + 1012
15 CoreFoundation 0x1e250 CFRunLoopRunSpecific + 572
16 GraphicsServices 0x1988 GSEventRunModal + 160
17 UIKitCore 0x4e5a94 -[UIApplication _run] + 1080
18 UIKitCore 0x27efd4 UIApplicationMain + 336
19 Ovada CM - PT 0x6070 main + 14 (AppDelegate.swift:14)
20 ??? 0x1029dc4d0 (Missing)
I am quite new to mobile dev so forgive me if some of this seems trivial. But I am trying to get a basic PageViewController working in Xamarin iOS with a number of different sign up controllers I have, for different stages of the app signup. So a user will fill in page one, click continue and be taken to step two and so forth.
I used a sample PageViewController project from GitHub and got that working on my simulator fine. However when I try and use it with my sign up controllers, I get an error
Foundation.MonoTouchException: Objective-C exception thrown. Name:
NSUnknownKeyException Reason: [
setValue:forUndefinedKey:]: this class is not key value
coding-compliant for the key DateOfBirthText.
This is the parent view controller OnLoad method
public override void ViewDidLoad()
{
base.ViewDidLoad();
_pageViewController = Storyboard.InstantiateViewController("SignInPageViewController") as UIPageViewController;
_pageViewController.DataSource = new PageViewControllerDataSource(this, _userInput);
var startVc = ViewControllerAtIndex(0);
var viewControllers = new[] {startVc};
_pageViewController.SetViewControllers(viewControllers, UIPageViewControllerNavigationDirection.Forward, false, null);
_pageViewController.View.Frame = new CGRect(0, 0, View.Frame.Width, View.Frame.Size.Height - 50);
AddChildViewController(_pageViewController);
View.AddSubview(_pageViewController.View);
_pageViewController.DidMoveToParentViewController(this);
}
It throws the error on line
_pageViewController.SetViewControllers
And this is the designer code for the child controller that tries to be loaded into the PageViewController and throws the error
{
[Register ("SigninViewControllerStageOne")]
partial class SigninViewControllerStageOne
{
[Outlet]
[GeneratedCode ("iOS Designer", "1.0")]
UITextField DateOfBirthText { get; set; }
[Outlet]
[GeneratedCode ("iOS Designer", "1.0")]
UITextField NameText { get; set; }
[Outlet]
[GeneratedCode ("iOS Designer", "1.0")]
UIButton NextStepButton { get; set; }
[Outlet]
[GeneratedCode ("iOS Designer", "1.0")]
UITextField PhoneNumberText { get; set; }
[Outlet]
[GeneratedCode ("iOS Designer", "1.0")]
UILabel TitleLabel { get; set; }
void ReleaseDesignerOutlets ()
{
if (DateOfBirthText != null) {
DateOfBirthText.Dispose ();
DateOfBirthText = null;
}
if (NameText != null) {
NameText.Dispose ();
NameText = null;
}
if (NextStepButton != null) {
NextStepButton.Dispose ();
NextStepButton = null;
}
if (PhoneNumberText != null) {
PhoneNumberText.Dispose ();
PhoneNumberText = null;
}
if (TitleLabel != null) {
TitleLabel.Dispose ();
TitleLabel = null;
}
}
}
}
Update: Full stack trace
Unhandled Exception:
Foundation.MonoTouchException: Objective-C exception thrown. Name:
NSUnknownKeyException Reason: [
setValue:forUndefinedKey:]: this class is not key value
coding-compliant for the key DateOfBirthText.
Native stack trace:
0 CoreFoundation 0x00958494
__exceptionPreprocess + 180
1 libobjc.A.dylib 0x08fd3e02
objc_exception_throw + 50
2 CoreFoundation 0x009580b1 -[NSException
raise] + 17
3 Foundation 0x014777f8
-[NSObject(NSKeyValueCoding) setValue:forUndefinedKey:] + 282
4 Foundation 0x013d1e6a
_NSSetUsingKeyValueSetter + 115
5 Foundation 0x013d1def
-[NSObject(NSKeyValueCoding) setValue:forKey:] + 295
6 UIKit 0x0397b931 -[UIViewController
setValue:forKey:] + 85
7 Foundation 0x0140654b
-[NSObject(NSKeyValueCoding) setValue:forKeyPath:] + 384
8 UIKit 0x03bf8a62
-[UIRuntimeOutletConnection connect] + 132
9 libobjc.A.dylib 0x08fe800c -[NSObject
performSelector:] + 62
10 CoreFoundation 0x00881131 -[NSArray
makeObjectsPerformSelector:] + 273
11 UIKit 0x03bf70fc -[UINib
instantiateWithOwner:options:] + 2102
12 UIKit 0x03983380 -[UIViewController
_loadViewFromNibNamed:bundle:] + 429
13 UIKit 0x03983db8 -[UIViewController
loadView] + 189
14 UIKit 0x039841c4 -[UIViewController
loadViewIfRequired] + 154
15 UIKit 0x03984ab1 -[UIViewController
view] + 35
16 UIKit 0x04038649
-[UIPageViewController _setViewControllers:withCurlOfType:fromLocation:direction:animated:notifyDelegate:completion:]
+ 2250
17 UIKit 0x0403a76a
-[UIPageViewController setViewControllers:direction:animated:completion:] + 309
18 ??? 0x1a6a07cc 0x0 + 443156428
19 ??? 0x1a69f6d0 0x0 + 443152080
20 ??? 0x18d3200f 0x0 + 416489487
21 ??? 0x18d29c1d 0x0 + 416455709
22 BarPandaApp 0x001be859
mono_jit_runtime_invoke + 921
23 BarPandaApp 0x0027d0ce
mono_runtime_invoke + 142
24 BarPandaApp 0x0035e225 xamarin_trampoline
+ 5605
25 UIKit 0x0397fb72 -[UIViewController
_sendViewDidLoadWithAppearanceProxyObjectTaggingEnabled] + 44
26 UIKit 0x03984692 -[UIViewController
loadViewIfRequired] + 1384
27 UIKit 0x039d02bb
-[UINavigationController _layoutViewController:] + 52
28 UIKit 0x039d0b75
-[UINavigationController _updateScrollViewFromViewController:toViewController:] + 421
29 UIKit 0x039d0d1c
-[UINavigationController _startTransition:fromViewController:toViewController:] + 145
30 UIKit 0x039d2118
-[UINavigationController _startDeferredTransitionIfNeeded:] + 1038
31 UIKit 0x039d339e
-[UINavigationController __viewWillLayoutSubviews] + 68
32 UIKit 0x03bb84b7
-[UILayoutContainerView layoutSubviews] + 252
33 UIKit 0x038843d4
-[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 810
34 libobjc.A.dylib 0x08fe8059 -[NSObject
performSelector:withObject:] + 70
35 QuartzCore 0x0b607096 -[CALayer
layoutSublayers] + 144
36 QuartzCore 0x0b5fa8b6
_ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 388
37 QuartzCore 0x0b5fa71a
_ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
38 QuartzCore 0x0b5ecee7
_ZN2CA7Context18commit_transactionEPNS_11TransactionE + 317
39 QuartzCore 0x0b621847
_ZN2CA11Transaction6commitEv + 561
40 QuartzCore 0x0b622108
_ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92
41 CoreFoundation 0x0086a75e
CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION + 30
42 CoreFoundation 0x0086a6be
__CFRunLoopDoObservers + 398
43 CoreFoundation 0x0085f868
CFRunLoopRunSpecific + 504
44 CoreFoundation 0x0085f65b CFRunLoopRunInMode
+ 123
45 UIKit 0x037ae2da -[UIApplication
_run] + 540
46 UIKit 0x037b3eb9 UIApplicationMain
+ 160
47 ??? 0x18d27144 0x0 + 416444740
48 ??? 0x18d26ef4 0x0 + 416444148
49 ??? 0x18d249a0 0x0 + 416434592
50 ??? 0x18d24620 0x0 + 416433696
51 ??? 0x18d24823 0x0 + 416434211
52 BarPandaApp 0x001be859
mono_jit_runtime_invoke + 921
53 BarPandaApp 0x0027d0ce
mono_runtime_invoke + 142
54 BarPandaApp 0x002822d1
mono_runtime_exec_main + 401
55 BarPandaApp 0x00282095
mono_runtime_run_main + 645
56 BarPandaApp 0x0013a3d5 mono_jit_exec +
213
57 BarPandaApp 0x0036d73a xamarin_main +
2474
58 BarPandaApp 0x0036e351 main + 65
59 libdyld.dylib 0x094ada25 start + 1
Actually, I don't think you should use UIPageViewController to implement the sign up progress.
But if you just need it, there is a sample I wrote for other, you can check this link to get it:
xamarin.ios implement PageController with images only code
I suggest you to use UINavigationController, It can make all you need, there is an example:
This is the code for AppDelegate(override the method "FinishedLaunching"):
public override bool FinishedLaunching (UIApplication application, NSDictionary launchOptions)
{
SignUpStepViewController step1 = new SignUpStepViewController (1, UIColor.Red);
SignUpStepViewController step2 = new SignUpStepViewController (2, UIColor.Green);
SignUpStepViewController step3 = new SignUpStepViewController (3, UIColor.Blue);
step1.SetNextController(step2);
step2.SetNextController(step3);
UINavigationController myNavigationController = new UINavigationController (step1);
this.Window = new UIWindow (UIScreen.MainScreen.Bounds);
this.Window.RootViewController = myNavigationController;
this.Window.MakeKeyAndVisible ();
return true;
}
This is the code for SignUpStepViewController:
public class SignUpStepViewController : UIViewController
{
public SignUpStepViewController (int index,UIColor color)
{
this.Title = "Step " + index;
this.View.BackgroundColor = color;
}
public void SetNextController(SignUpStepViewController nextC)
{
UIBarButtonItem btnContinue = new UIBarButtonItem ("Continue",UIBarButtonItemStyle.Done, delegate {
this.NavigationController.PushViewController(nextC,true);
});
this.NavigationItem.SetRightBarButtonItem (btnContinue,true);
}
}
Hope it can help you.
If you still need help, just leave the message here, I will check latter.
I am attempting to display Instagram Comments in a Detail View Controller. I am pushing the data from a Master View Controller shown below:
MessageViewController *message = [[MessageViewController alloc] init];
NSInteger row = [[self tableView].indexPathForSelectedRow row];
NSDictionary *pic = [instaPics objectAtIndex:row];
message.instagramData = pic;
[self.navigationController pushViewController:message animated:YES];
However when I tap the button to go to the Detail View Controller I get this error:
2015-05-02 01:29:56.464 Floadt[40646:4284271] Successfully commented Picture
2015-05-02 01:29:56.516 Floadt[40646:4284271] -[__NSCFArray objectForKeyedSubscript:]: unrecognized selector sent to instance 0x7fd06be6cc40
2015-05-02 01:29:56.529 Floadt[40646:4284271] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFArray objectForKeyedSubscript:]: unrecognized selector sent to instance 0x7fd06be6cc40'
*** First throw call stack:
(
0 CoreFoundation 0x000000010dc5bc65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010d537bb7 objc_exception_throw + 45
2 CoreFoundation 0x000000010dc630ad -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x000000010dbb913c ___forwarding___ + 988
4 CoreFoundation 0x000000010dbb8cd8 _CF_forwarding_prep_0 + 120
5 Floadt 0x000000010a1104d0 -[MessageViewController messageCellForRowAtIndexPath:] + 256
6 Floadt 0x000000010a11035c -[MessageViewController tableView:cellForRowAtIndexPath:] + 188
7 UIKit 0x000000010c36ca28 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 508
8 UIKit 0x000000010c34b248 -[UITableView _updateVisibleCellsNow:isRecursive:] + 2853
9 UIKit 0x000000010c3618a9 -[UITableView layoutSubviews] + 210
10 UIKit 0x000000010c2eba2b -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 536
11 QuartzCore 0x000000010c0afec2 -[CALayer layoutSublayers] + 146
12 QuartzCore 0x000000010c0a46d6 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
13 UIKit 0x000000010c2df675 -[UIView(Hierarchy) layoutBelowIfNeeded] + 607
14 Floadt 0x000000010a0908a8 -[SLKTextViewController viewWillAppear:] + 296
15 UIKit 0x000000010c39ffa1 -[UIViewController _setViewAppearState:isAnimating:] + 487
16 UIKit 0x000000010c3c1395 -[UINavigationController _startCustomTransition:] + 887
17 UIKit 0x000000010c3cd3bf -[UINavigationController _startDeferredTransitionIfNeeded:] + 386
18 UIKit 0x000000010c3cdf0e -[UINavigationController __viewWillLayoutSubviews] + 43
19 UIKit 0x000000010c518715 -[UILayoutContainerView layoutSubviews] + 202
20 UIKit 0x000000010c2eba2b -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 536
21 QuartzCore 0x000000010c0afec2 -[CALayer layoutSublayers] + 146
22 QuartzCore 0x000000010c0a46d6 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
23 QuartzCore 0x000000010c0a4546 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
24 QuartzCore 0x000000010c010886 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 242
25 QuartzCore 0x000000010c011a3a _ZN2CA11Transaction6commitEv + 462
26 QuartzCore 0x000000010c0120eb _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 89
27 CoreFoundation 0x000000010db8eca7 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
28 CoreFoundation 0x000000010db8ec00 __CFRunLoopDoObservers + 368
29 CoreFoundation 0x000000010db84a33 __CFRunLoopRun + 1123
30 CoreFoundation 0x000000010db84366 CFRunLoopRunSpecific + 470
31 GraphicsServices 0x000000010f611a3e GSEventRunModal + 161
32 UIKit 0x000000010c26b900 UIApplicationMain + 1282
33 Floadt 0x000000010a113c5f main + 111
34 libdyld.dylib 0x000000010fe26145 start + 1
35 ??? 0x0000000000000001 0x0 + 1
)
Here is my setup code for adding a UITableViewCell to the Table View Controller:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 2;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
return [self messageCellForRowAtIndexPath:indexPath];
}
- (MessageTableViewCell *)messageCellForRowAtIndexPath:(NSIndexPath *)indexPath
{
MessageTableViewCell *cell = (MessageTableViewCell *)[self.tableView dequeueReusableCellWithIdentifier:MessengerCellIdentifier];
NSDictionary *instaPics = self.instagramData;
NSString *commentText = instaPics[#"comments"][#"data"][#"text"];
Message *message = self.messages[indexPath.row];
cell.titleLabel.text = message.username;
cell.bodyLabel.text = commentText;
if (message.attachment) {
cell.attachmentView.image = message.attachment;
cell.attachmentView.layer.shouldRasterize = YES;
cell.attachmentView.layer.rasterizationScale = [UIScreen mainScreen].scale;
}
cell.indexPath = indexPath;
cell.usedForMessage = YES;
if (cell.needsPlaceholder)
{
CGFloat scale = [UIScreen mainScreen].scale;
if ([[UIScreen mainScreen] respondsToSelector:#selector(nativeScale)]) {
scale = [UIScreen mainScreen].nativeScale;
}
CGSize imgSize = CGSizeMake(kAvatarSize*scale, kAvatarSize*scale);
[LoremIpsum asyncPlaceholderImageWithSize:imgSize
completion:^(UIImage *image) {
UIImage *thumbnail = [UIImage imageWithCGImage:image.CGImage scale:scale orientation:UIImageOrientationUp];
cell.thumbnailView.image = thumbnail;
cell.thumbnailView.layer.shouldRasterize = YES;
cell.thumbnailView.layer.rasterizationScale = [UIScreen mainScreen].scale;
}];
}
// Cells must inherit the table view's transform
// This is very important, since the main table view may be inverted
cell.transform = self.tableView.transform;
return cell;
}
Instagram JSON Data:
{
attribution = "<null>";
caption = {
"created_time" = 1430594453;
from = {
"full_name" = "Siwani Regmi";
id = 247899182;
"profile_picture" = "https://igcdn-photos-g-a.akamaihd.net/hphotos-ak-xpa1/t51.2885-19/10948979_810376228999798_661235337_a.jpg";
username = "siwani_32";
};
id = 976219494210952254;
text = "perfect night with the most perfect man\Ud83d\Ude1b\Ud83c\Udf89\U2728 #seniorprom";
};
comments = {
count = 0;
data = (
);
};
"created_time" = 1430594453;
filter = Normal;
id = "976219491862142549_247899182";
images = {
"low_resolution" = {
height = 306;
url = "https://scontent.cdninstagram.com/hphotos-xap1/t51.2885-15/s306x306/e15/11191276_1060001617348197_1550964556_n.jpg";
width = 306;
};
"standard_resolution" = {
height = 640;
url = "https://scontent.cdninstagram.com/hphotos-xap1/t51.2885-15/e15/11191276_1060001617348197_1550964556_n.jpg";
width = 640;
};
thumbnail = {
height = 150;
url = "https://scontent.cdninstagram.com/hphotos-xap1/t51.2885-15/s150x150/e15/11191276_1060001617348197_1550964556_n.jpg";
width = 150;
};
};
likes = {
count = 17;
data = (
{
"full_name" = "Bridget Carroll";
id = 223765496;
"profile_picture" = "https://igcdn-photos-e-a.akamaihd.net/hphotos-ak-xpa1/t51.2885-19/11208422_409436919229236_670022667_a.jpg";
username = "bridget_carroll33";
},
{
"full_name" = "";
id = 190249955;
"profile_picture" = "https://igcdn-photos-g-a.akamaihd.net/hphotos-ak-xaf1/t51.2885-19/10747956_726218724133062_1939114518_a.jpg";
username = hayleymarierussell;
},
{
"full_name" = "Jill Bracaglia";
id = 205453413;
"profile_picture" = "https://instagramimages-a.akamaihd.net/profiles/profile_205453413_75sq_1373835555.jpg";
username = "jilli_beanz";
},
{
"full_name" = "Priya Nakhre";
id = 177807366;
"profile_picture" = "https://igcdn-photos-c-a.akamaihd.net/hphotos-ak-xtp1/t51.2885-19/11098479_870674976323434_1264837026_a.jpg";
username = priyanakhre;
}
);
};
link = "https://instagram.com/p/2MOnSjQV5V/";
location = {
id = 764529229;
};
tags = (
seniorprom
);
type = image;
user = {
"full_name" = "Siwani Regmi";
id = 247899182;
"profile_picture" = "https://igcdn-photos-g-a.akamaihd.net/hphotos-ak-xpa1/t51.2885-19/10948979_810376228999798_661235337_a.jpg";
username = "siwani_32";
};
"user_has_liked" = 0;
"users_in_photo" = (
{
position = {
x = "0.358666667";
y = "0.32";
};
user = {
"full_name" = "Sahan Pandey \U26bd";
id = 435571613;
"profile_picture" = "https://igcdn-photos-a-a.akamaihd.net/hphotos-ak-xpa1/t51.2885-19/10727510_301263856731264_1868575282_a.jpg";
username = pandeyexpress;
};
}
);
}
I am attempting to display an array which I receive from a JSON Dictionary onto a UITableView but I keep getting an error. I am trying to display all the comments for a given Instagram Picture onto a Table. Here is how I am attempting to display the cells:
MessageTableViewCell *cell = (MessageTableViewCell *)[self.tableView dequeueReusableCellWithIdentifier:MessengerCellIdentifier];
NSDictionary *instaPics = self.instagramData;
NSArray *commentArray = instaPics[#"comments"][#"data"];
NSString *commentText = [commentArray valueForKey:#"text"]; // Error occurs here
Message *message = self.messages[indexPath.row];
cell.titleLabel.text = message.username;
cell.bodyLabel.text = commentText;
Here is the error I receive:
-[__NSArrayI length]: unrecognized selector sent to instance 0x7f913052db10
2015-05-05 22:16:08.848 Floadt[6061:514032] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI length]: unrecognized selector sent to instance 0x7f913052db10'
*** First throw call stack:
(
0 CoreFoundation 0x0000000107d60c65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010763cbb7 objc_exception_throw + 45
2 CoreFoundation 0x0000000107d680ad -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x0000000107cbe13c ___forwarding___ + 988
4 CoreFoundation 0x0000000107cbdcd8 _CF_forwarding_prep_0 + 120
5 UIKit 0x0000000106543ab4 -[UILabel _textRectForBounds:limitedToNumberOfLines:includingShadow:] + 65
6 UIKit 0x000000010654390f -[UILabel textRectForBounds:limitedToNumberOfLines:] + 76
7 UIKit 0x00000001065473b9 -[UILabel _intrinsicSizeWithinSize:] + 170
8 UIKit 0x0000000106547499 -[UILabel intrinsicContentSize] + 76
9 UIKit 0x00000001069e5b6c -[UIView(UIConstraintBasedLayout) _generateContentSizeConstraints] + 33
10 UIKit 0x00000001069e5930 -[UIView(UIConstraintBasedLayout) _updateContentSizeConstraints] + 422
11 UIKit 0x00000001069ecd25 -[UIView(AdditionalLayoutSupport) updateConstraints] + 162
12 UIKit 0x0000000106547304 -[UILabel updateConstraints] + 274
13 UIKit 0x00000001069ec346 -[UIView(AdditionalLayoutSupport) _internalUpdateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:] + 242
14 UIKit 0x00000001069ec53e -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:] + 124
15 CoreFoundation 0x0000000107c67354 CFArrayApplyFunction + 68
16 UIKit 0x00000001069ec2ed -[UIView(AdditionalLayoutSupport) _internalUpdateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:] + 153
17 Foundation 0x0000000105b021be -[NSISEngine withBehaviors:performModifications:] + 155
18 UIKit 0x00000001069ec53e -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:] + 124
19 CoreFoundation 0x0000000107c67354 CFArrayApplyFunction + 68
20 UIKit 0x00000001069ec2ed -[UIView(AdditionalLayoutSupport) _internalUpdateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:] + 153
21 UIKit 0x00000001069ec53e -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededAccumulatingViewsNeedingSecondPassAndViewsNeedingBaselineUpdate:] + 124
22 UIKit 0x00000001069eca0e __60-[UIView(AdditionalLayoutSupport) updateConstraintsIfNeeded]_block_invoke + 96
23 UIKit 0x00000001069ec6d6 -[UIView(AdditionalLayoutSupport) updateConstraintsIfNeeded] + 231
24 UIKit 0x00000001067d7531 -[UITableViewCellContentView updateConstraintsIfNeeded] + 94
25 UIKit 0x00000001069ecdde -[UIView(AdditionalLayoutSupport) _updateConstraintsAtEngineLevelIfNeeded] + 146
26 UIKit 0x00000001063e4a3d -[UIView(Hierarchy) _updateConstraintsAsNecessaryAndApplyLayoutFromEngine] + 114
27 UIKit 0x00000001063f0a2b -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 536
28 QuartzCore 0x00000001061b4ec2 -[CALayer layoutSublayers] + 146
29 QuartzCore 0x00000001061a96d6 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
30 UIKit 0x00000001063e4675 -[UIView(Hierarchy) layoutBelowIfNeeded] + 607
31 Floadt 0x0000000104195848 -[SLKTextViewController viewWillAppear:] + 296
32 UIKit 0x00000001064a4fa1 -[UIViewController _setViewAppearState:isAnimating:] + 487
33 UIKit 0x00000001064c6395 -[UINavigationController _startCustomTransition:] + 887
34 UIKit 0x00000001064d23bf -[UINavigationController _startDeferredTransitionIfNeeded:] + 386
35 UIKit 0x00000001064d2f0e -[UINavigationController __viewWillLayoutSubviews] + 43
36 UIKit 0x000000010661d715 -[UILayoutContainerView layoutSubviews] + 202
37 UIKit 0x00000001063f0a2b -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 536
38 QuartzCore 0x00000001061b4ec2 -[CALayer layoutSublayers] + 146
39 QuartzCore 0x00000001061a96d6 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
40 QuartzCore 0x00000001061a9546 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
41 QuartzCore 0x0000000106115886 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 242
42 QuartzCore 0x0000000106116a3a _ZN2CA11Transaction6commitEv + 462
43 UIKit 0x000000010636d626 _UIApplicationHandleEventQueue + 2140
44 CoreFoundation 0x0000000107c94431 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
45 CoreFoundation 0x0000000107c8a2fd __CFRunLoopDoSources0 + 269
46 CoreFoundation 0x0000000107c89934 __CFRunLoopRun + 868
47 CoreFoundation 0x0000000107c89366 CFRunLoopRunSpecific + 470
48 GraphicsServices 0x0000000109716a3e GSEventRunModal + 161
49 UIKit 0x0000000106370900 UIApplicationMain + 1282
50 Floadt 0x0000000104218c5f main + 111
51 libdyld.dylib 0x0000000109f2b145 start + 1
52 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
Here is an example copy of the JSON:
{
attribution = "<null>";
caption = {
"created_time" = 1430877943;
from = {
"full_name" = "Shreya M.";
id = 25085898;
"profile_picture" = "https://igcdn-photos-h-a.akamaihd.net/hphotos-ak-xaf1/t51.2885-19/10890672_320752588135679_1815913692_a.jpg";
username = "shreya_mandava";
};
id = 978597576956579585;
text = "9+10????";
};
comments = {
count = 2;
data = (
{
"created_time" = 1430878007;
from = {
"full_name" = "Aleesha Toteja";
id = 17117902;
"profile_picture" = "https://instagramimages-a.akamaihd.net/profiles/profile_17117902_75sq_1373927314.jpg";
username = leeshtotes;
};
id = 978598112887967529;
text = "DIRT \Ud83d\Ude3b";
},
{
"created_time" = 1430878307;
from = {
"full_name" = "Shritha M.";
id = 375799796;
"profile_picture" = "https://igcdn-photos-f-a.akamaihd.net/hphotos-ak-xpf1/t51.2885-19/10454159_1056687271012469_2048676049_a.jpg";
username = "shritha_m";
};
id = 978600630846098439;
text = sigh;
}
);
};
"created_time" = 1430877943;
filter = Normal;
id = "978597574314167442_25085898";
images = {
"low_resolution" = {
height = 306;
url = "https://scontent.cdninstagram.com/hphotos-xfa1/t51.2885-15/s306x306/e15/11241842_1401517966839213_670743424_n.jpg";
width = 306;
};
"standard_resolution" = {
height = 640;
url = "https://scontent.cdninstagram.com/hphotos-xfa1/t51.2885-15/e15/11241842_1401517966839213_670743424_n.jpg";
width = 640;
};
thumbnail = {
height = 150;
url = "https://scontent.cdninstagram.com/hphotos-xfa1/t51.2885-15/s150x150/e15/11241842_1401517966839213_670743424_n.jpg";
width = 150;
};
};
likes = {
count = 22;
data = (
{
"full_name" = "Ronak Chopra";
id = 347652824;
"profile_picture" = "https://scontent.cdninstagram.com/hphotos-xpa1/t51.2885-19/11142328_1644920965736964_1040275960_a.jpg";
username = "conak_rhopra";
},
{
"full_name" = "emily bach";
id = 292615252;
"profile_picture" = "https://igcdn-photos-a-a.akamaihd.net/hphotos-ak-xap1/t51.2885-19/10454121_1558984144374824_122699173_a.jpg";
username = "emily_bach_";
},
{
"full_name" = "\Ud83c\Udf38Trisha\Ud83c\Udf38";
id = 303629882;
"profile_picture" = "https://igcdn-photos-g-a.akamaihd.net/hphotos-ak-xfp1/t51.2885-19/10955125_708435799269374_749376734_a.jpg";
username = trishddishh;
},
{
"full_name" = "Shritha M.";
id = 375799796;
"profile_picture" = "https://igcdn-photos-f-a.akamaihd.net/hphotos-ak-xpf1/t51.2885-19/10454159_1056687271012469_2048676049_a.jpg";
username = "shritha_m";
}
);
};
link = "https://instagram.com/p/2UrU8bDgyS/";
location = {
id = 772010926;
latitude = "38.913782928";
longitude = "-77.383238738";
name = "ft. dirt";
};
tags = (
);
type = image;
user = {
"full_name" = "Shreya M.";
id = 25085898;
"profile_picture" = "https://igcdn-photos-h-a.akamaihd.net/hphotos-ak-xaf1/t51.2885-19/10890672_320752588135679_1815913692_a.jpg";
username = "shreya_mandava";
};
"user_has_liked" = 0;
"users_in_photo" = (
{
position = {
x = "0.6703125";
y = "0.246875";
};
user = {
"full_name" = "John Nguyen";
id = 1477626916;
"profile_picture" = "https://igcdn-photos-d-a.akamaihd.net/hphotos-ak-xfp1/t51.2885-19/11018467_1431648953794187_659343544_a.jpg";
username = bumbonguyen;
};
}
);
}
You are trying to get a value from key in a NSArray on:
[commentArray valueForKey:#"text"];
NSArray is not a dictionary has not keys (has multiple comments), should be accessed by his index.
[[commentArray objectAtIndex:0] valueForKey:#"text"];
Probably you will want, iterate over the comments and on each comment get his "text"
You can replace this line :
NSString *commentText = [commentArray valueForKey:#"text"];
with
for (NSDictionary *comment in commentArray ) {
NSString *commentText = [comment valueForKey:#"text"];
cell.bodyLabel.text = commentText;
}
Gonzalo is right. Your accessing commentArray like a NSDictionary but it is actually a NSArray. That causes the crash.
NSArray *commentArray = instaPics[#"comments"][#"data"];
It looks like a wrong access of key value..
As per my understanding you are trying to get value of comments.
your Json data contains root & child key value like,
comments
count
Data
caption
images
likes
...
Here your Comments having child value like count,data.
So can write the code to fetch value of comment > data>text
--------1--------
NSMutableDictionary *response = [[[json valueForKey:#"comments"] objectAtIndex:0]mutableCopy];
NSMutableDictionary *data = [[[response valueForKey:#"data"] objectAtIndex:0]mutableCopy];
NSString *text = [data valueForKey:#"text"];
----OR----2--------
NSMutableDictionary *response = [[[json valueForKey:#"comments"] objectAtIndex:0]mutableCopy];
NSArray *textarr=[response valueForKey:#"text"];
After I have updated monotouch to Version 5.2.13 my App crashes when I touched inside a UIButton.
About my Code: (it's a question of a LoginView):
I have a UIViewController which includes a ScrollView.
For each User the ScrollView provides a UIView (the UserImageView).
This UserImageView contains a UserImage, Username and so on. Over the UserImage lays a UIButton which should catches the Touch-Events to selected a User.
This Button causes the Exception below more precisely the HitTest method from the UIView.
I get the following Stacktrace:
Stacktrace:
at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr) <IL 0x0009f, 0xffffffff>
at MonoTouch.UIKit.UIApplication.Main (string[],string,string) [0x00042] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:29
at MF.Stationaer.iPad.Application.Main (string[]) <IL 0x00028, 0x00073>
at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) <IL 0x00050, 0xffffffff>
Native stacktrace:
0 MFiPad_MD 0x0009061c mono_handle_native_sigsegv + 284
1 MFiPad_MD 0x000059a8 mono_sigsegv_signal_handler + 248
2 libsystem_c.dylib 0x92cd259b _sigtramp + 43
3 ??? 0xffffffff 0x0 + 4294967295
4 UIKit 0x0228c741 __38-[UIView(Geometry) hitTest:withEvent:]_block_invoke_0 + 96
5 CoreFoundation 0x0116cf1a __NSArrayChunkIterate + 362
6 CoreFoundation 0x01138635 __NSArrayEnumerate + 997
7 CoreFoundation 0x01138026 -[NSArray enumerateObjectsWithOptions:usingBlock:] + 102
8 UIKit 0x0228c66b -[UIView(Geometry) hitTest:withEvent:] + 646
9 UIKit 0x0228c765 __38-[UIView(Geometry) hitTest:withEvent:]_block_invoke_0 + 132
10 CoreFoundation 0x0116cf1a __NSArrayChunkIterate + 362
11 CoreFoundation 0x01138635 __NSArrayEnumerate + 997
12 CoreFoundation 0x01138026 -[NSArray enumerateObjectsWithOptions:usingBlock:] + 102
13 UIKit 0x0228c66b -[UIView(Geometry) hitTest:withEvent:] + 646
14 UIKit 0x022a1157 -[UIScrollView hitTest:withEvent:] + 79
15 UIKit 0x0228c765 __38-[UIView(Geometry) hitTest:withEvent:]_block_invoke_0 + 132
16 CoreFoundation 0x0116cf1a __NSArrayChunkIterate + 362
17 CoreFoundation 0x01138635 __NSArrayEnumerate + 997
18 CoreFoundation 0x01138026 -[NSArray enumerateObjectsWithOptions:usingBlock:] + 102
19 UIKit 0x0228c66b -[UIView(Geometry) hitTest:withEvent:] + 646
20 UIKit 0x0228c765 __38-[UIView(Geometry) hitTest:withEvent:]_block_invoke_0 + 132
21 CoreFoundation 0x0116cf1a __NSArrayChunkIterate + 362
22 CoreFoundation 0x01138635 __NSArrayEnumerate + 997
23 CoreFoundation 0x01138026 -[NSArray enumerateObjectsWithOptions:usingBlock:] + 102
24 UIKit 0x0228c66b -[UIView(Geometry) hitTest:withEvent:] + 646
25 UIKit 0x0228c765 __38-[UIView(Geometry) hitTest:withEvent:]_block_invoke_0 + 132
26 CoreFoundation 0x0116cf1a __NSArrayChunkIterate + 362
27 CoreFoundation 0x01138635 __NSArrayEnumerate + 997
28 CoreFoundation 0x01138026 -[NSArray enumerateObjectsWithOptions:usingBlock:] + 102
29 UIKit 0x0228c66b -[UIView(Geometry) hitTest:withEvent:] + 646
30 UIKit 0x02286dbd +[UIWindow _hitTestToPoint:pathIndex:forEvent:] + 378
31 UIKit 0x02258ca0 _UIApplicationHandleEvent + 1648
32 GraphicsServices 0x047c5ef5 PurpleEventCallback + 1274
33 CoreFoundation 0x011a9195 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
34 CoreFoundation 0x0110dff2 __CFRunLoopDoSource1 + 146
35 CoreFoundation 0x0110c8da __CFRunLoopRun + 2218
36 CoreFoundation 0x0110bd84 CFRunLoopRunSpecific + 212
37 CoreFoundation 0x0110bc9b CFRunLoopRunInMode + 123
38 GraphicsServices 0x047c47d8 GSEventRunModal + 190
39 GraphicsServices 0x047c488a GSEventRun + 103
40 UIKit 0x02258626 UIApplicationMain + 1163
41 ??? 0x0b96e514 0x0 + 194438420
42 ??? 0x0b96d6c0 0x0 + 194434752
43 ??? 0x0b96d33c 0x0 + 194433852
44 ??? 0x0b96d42f 0x0 + 194434095
45 MFiPad_MD 0x00009d12 mono_jit_runtime_invoke + 722
46 MFiPad_MD 0x00169e4e mono_runtime_invoke + 126
47 MFiPad_MD 0x0016df34 mono_runtime_exec_main + 420
48 MFiPad_MD 0x001732e5 mono_runtime_run_main + 725
49 MFiPad_MD 0x00066f15 mono_jit_exec + 149
50 MFiPad_MD 0x002115d5 main + 2837
51 MFiPad_MD 0x00002d65 start + 53
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
Here is the important Part of my Code:
public class LoginViewController : UIViewController
{
...
public override void ViewDidLoad()
{
...
BuildUserUI();
...
}
private void BuildUserUI()
{
currentIconLocation = new PointF(50, 10);
for (var i = 0; i < UserList.List.Count; i++)
CreateUserInGrid(UserList.GetUserByIndex(i));
}
private void CreateUserInGrid(LoginUser user)
{
var imgFrame = new RectangleF(currentIconLocation.X, currentIconLocation.Y, 140, 170);
var loginImg = new UILoginImage(imgFrame);
loginImg.Image = user.Image ?? defaultUserImage.CGImage;
loginImg.Name = user.Nachname;
if (!string.IsNullOrEmpty(user.Vorname))
loginImg.Name += ", " + user.Vorname;
loginImg.Tag = user.UserIndex;
loginImg.AddTarget(this, new Selector("ShowNumberPad:"), UIControlEvent.TouchUpInside);
loginImg.LoginUser = user;
scrollView.AddSubview(loginImg);
loginImages.Add(loginImg);
limitedScrollView.UserInteractionEnabled = false;
var newSize = new SizeF(scrollView.Frame.Size.Width, currentIconLocation.Y + imgFrame.Size.Height + 20);
scrollView.ContentSize = newSize;
limitedScrollView.ContentSize = new SizeF(limitedScrollView.Frame.Size.Width, limitedScrollView.Frame.Size.Height);
currentIconLocation.X += imgFrame.Size.Width;
if (currentIconLocation.X + imgFrame.Size.Width > scrollView.Frame.Size.Width)
{
currentIconLocation.Y += imgFrame.Size.Height;
currentIconLocation.X = 50;
}
}
[Export("ShowNumberPad:")]
private void ShowNumberPad(NSObject sender)
{
...
}
}
public class UILoginImage : UIView
{
[Export("initWithFrame:")]
public UILoginImage(RectangleF frame)
: base(frame)
{
var shadowFrame = new RectangleF(0, 0, 117, 148);
wrapperControl = new UIControl(shadowFrame);
AddSubview(wrapperControl);
shadowImage = new UIImageView(shadowFrame);
shadowImage.Image = ImageCache.GetResourceImage("Images/Login/LoginSchatten.png");
wrapperControl.AddSubview(shadowImage);
var mainBackFrame = new RectangleF(8, 9, 98, 128);
whiteBackgroundImage = new UIImageView(mainBackFrame);
whiteBackgroundImage.Image = ImageCache.GetResourceImage("Images/Login/Singlewhite.png");
wrapperControl.AddSubview(whiteBackgroundImage);
var imageFrame = new RectangleF(13, 15, 87, 116);
clickHelper = UIButton.FromType(UIButtonType.Custom);
clickHelper.Frame = imageFrame;
wrapperControl.AddSubview(clickHelper);
userImage = new UIImageView(imageFrame);
AddSubview(userImage);
var mitarbeiterlabelFrame = new RectangleF(-12, 137, 140, 25);
mitarbeiterNameLabel = new FontSizeLabel(mitarbeiterlabelFrame);
mitarbeiterNameLabel.TextAlignment = UITextAlignment.Center;
mitarbeiterNameLabel.Font = UIFont.SystemFontOfSize(12);
mitarbeiterNameLabel.Opaque = false;
mitarbeiterNameLabel.BackgroundColor = UIColor.Clear;
AddSubview(mitarbeiterNameLabel);
var benutzerlabelFrame = new RectangleF(mitarbeiterlabelFrame.X, mitarbeiterlabelFrame.Y + 13, 140, 25);
benutzerNameLabel = new FontSizeLabel(benutzerlabelFrame);
benutzerNameLabel.TextAlignment = UITextAlignment.Center;
benutzerNameLabel.Font = UIFont.SystemFontOfSize(10);
benutzerNameLabel.Opaque = false;
benutzerNameLabel.BackgroundColor = UIColor.Clear;
benutzerNameLabel.TextColor = UIColor.DarkGray;
AddSubview(benutzerNameLabel);
}
public void AddTarget(NSObject target, Selector action, UIControlEvent controlEvents)
{
clickHelper.AddTarget(target, action, controlEvents);
}
public void RemoveTarget(NSObject target, Selector action, UIControlEvent controlEvents)
{
clickHelper.RemoveTarget(target, action, controlEvents);
}
}
I'm not sure your use of AddTarget is a good way to hook up a UIButton's click.
You should be using clickHelper.TouchUpInside to wire up click events. This is a standard C# event.
Another option would be to wire up an action to this event inside your XIB file in XCode.