0

我找到了我需要这样做的 Objective-c 但是你将如何用 ruby​​ 重写它?

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{  
    [self performSelector:@selector(fixRoundedSplitViewCorner) withObject:NULL afterDelay:0];
}

-(void) fixRoundedSplitViewCorner {  
    [self explode:[[UIApplication sharedApplication] keyWindow] level:0];  
}

-(void) explode:(id)aView level:(int)level 
{   
    if ([aView isKindOfClass:[UIImageView class]]) {
        UIImageView* roundedCornerImage = (UIImageView*)aView;
        roundedCornerImage.hidden = YES;
    }
    if (level < 2) 
    {
        for (UIView *subview in [aView subviews]) {
            [self explode:subview level:(level + 1)];
        }
    }
}
4

1 回答 1

1

像这样的东西怎么样:

def didRotateFromInterfaceOrientation(fromInterfaceOrientation)
# you can just skip calling performSelector and call the method directly
#   self.performSelector('fixRoundedSplitViewCorner', withObject:nil, afterDelay:0)
    self.fixRoundedSplitViewCorner()
end

def fixRoundedSplitViewCorner
    self.explode(UIApplication.sharedApplication.keyWindow, level:0)
end

def explode(aView, level:level)
    if aView.class == UIImageView
        aView.hidden = true
    end
    if level < 2
        for subview in aView.subviews
            self.explode(subview, level:(level + 1))
        end
    end
end
于 2012-08-28T14:40:43.040 回答