- (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;
}