长按复制

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

- (void)awakeFromNib {
    [super awakeFromNib];
    
    UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(problemToCopy:)];
    longPress.numberOfTouchesRequired = 1;
    [self addGestureRecognizer:longPress];
   
    // Initialization code
}

- (void)problemToCopy:(UILongPressGestureRecognizer *)gesture {
    if (gesture.state == UIGestureRecognizerStateBegan){
        QHPiMomentsCopyTextViewController *copy = [[QHPiMomentsCopyTextViewController alloc] initWithNibName:@"QHPiMomentsCopyTextViewController" bundle:nil];
        copy.textToCopy = self.myReplyLabel.text;
        
        if (isIOS8) {
            
            copy.modalPresentationStyle = UIModalPresentationOverCurrentContext;
            
            [[self obtainShowVC] presentViewController:copy animated:NO completion:^{
                
            }];
        }else
        {
            [UIApplication sharedApplication].keyWindow.rootViewController.modalPresentationStyle = UIModalPresentationCurrentContext;
            
            [[self obtainShowVC] presentViewController:copy animated:NO completion:nil];
            
        }
    }
}

- (UIViewController *)obtainShowVC
{
    
    UITabBarController *tabCtrl = (UITabBarController *)[UIApplication sharedApplication].keyWindow.rootViewController;
    UINavigationController *navi = tabCtrl.selectedViewController;
    UIViewController *vc = [navi visibleViewController];
    return vc;
    
}

 

转载于:https://my.oschina.net/u/2519763/blog/783797

你可能感兴趣的:(python)