- Fix for 'hold for delete' for cells in teams table ios-revival
authorantonc27 <antonc27@mail.ru>
Sun, 16 Aug 2015 02:32:03 +0200
branchios-revival
changeset 11135 b34c0e2b546a
parent 11134 41cfa8edf02f
child 11136 9b5f60bc059e
- Fix for 'hold for delete' for cells in teams table
project_files/HedgewarsMobile/Classes/HoldTableViewCell.m
--- a/project_files/HedgewarsMobile/Classes/HoldTableViewCell.m	Sat Aug 15 20:49:06 2015 +0200
+++ b/project_files/HedgewarsMobile/Classes/HoldTableViewCell.m	Sun Aug 16 02:32:03 2015 +0200
@@ -57,7 +57,29 @@
 
 -(void) holdAction {
     if (self.delegate != nil && [self.delegate respondsToSelector:@selector(holdAction:onTable:)])
-        [self.delegate holdAction:self.textLabel.text onTable:(UITableView *)self.superview];
+    {
+        UITableView *tableView = [self findTable];
+        if (tableView)
+        {
+            [self.delegate holdAction:self.textLabel.text onTable:tableView];
+        }
+    }
+}
+
+- (UITableView *)findTable
+{
+    UIView *tableView = self.superview;
+    while (![tableView isKindOfClass:[UITableView class]] || (tableView == nil))
+    {
+        tableView = tableView.superview;
+        
+        if ([tableView isEqual:self.window])
+        {
+            tableView = nil;
+        }
+    }
+    
+    return (UITableView *)tableView;
 }
 
 -(void) dealloc {