|
|
@@ -18,7 +18,89 @@
|
|
|
#import <QuickLook/QuickLook.h>
|
|
|
#import "DetailCellKVNew.h"
|
|
|
|
|
|
-@interface DetailPageViewController () <QLPreviewControllerDataSource,QLPreviewControllerDelegate>
|
|
|
+@interface DetailHUD : UIView
|
|
|
+
|
|
|
+@property (nonatomic,strong) UILabel *msgLb;
|
|
|
+
|
|
|
+@end
|
|
|
+
|
|
|
+@implementation DetailHUD
|
|
|
+
|
|
|
++ (void)show:(NSString *)msg inView:(UIView *)view {
|
|
|
+
|
|
|
+ if (!msg) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ DetailHUD *hud = [[DetailHUD alloc] initWithFrame:CGRectZero];
|
|
|
+ hud.backgroundColor = [UIColor colorWithRed:0.2 green:0.2 blue:0.2 alpha:0.9];
|
|
|
+ hud.msgLb.text = msg;
|
|
|
+ [hud layoutSize];
|
|
|
+ for (UIView *sub in view.subviews) {
|
|
|
+ if ([sub isKindOfClass:self]) {
|
|
|
+ sub.hidden = YES;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ [view addSubview:hud];
|
|
|
+
|
|
|
+ [hud performSelector:@selector(hide) withObject:nil afterDelay:3.0f];
|
|
|
+}
|
|
|
+
|
|
|
+- (UILabel *)msgLb {
|
|
|
+ if (!_msgLb) {
|
|
|
+ _msgLb = [[UILabel alloc] initWithFrame:CGRectZero];
|
|
|
+ _msgLb.textColor = [UIColor whiteColor];
|
|
|
+ _msgLb.font = [UIFont systemFontOfSize:14.0f];
|
|
|
+
|
|
|
+ [self addSubview:_msgLb];
|
|
|
+ }
|
|
|
+ return _msgLb;
|
|
|
+}
|
|
|
+
|
|
|
+- (void)layoutSize {
|
|
|
+ [self.msgLb sizeToFit];
|
|
|
+ CGSize size = self.msgLb.bounds.size;
|
|
|
+
|
|
|
+ CGFloat height = size.height + 20;
|
|
|
+ CGFloat width = size.width + 20;
|
|
|
+ if (height < 30) {
|
|
|
+ height = 30;
|
|
|
+ }
|
|
|
+ if (width < 30) {
|
|
|
+ width = 30;
|
|
|
+ }
|
|
|
+
|
|
|
+ self.msgLb.center = CGPointMake(width * 0.5, height * 0.5);
|
|
|
+ self.bounds = CGRectMake(0, 0, width, height);
|
|
|
+
|
|
|
+ self.layer.cornerRadius = 5.0f;
|
|
|
+ self.layer.masksToBounds = YES;
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+- (void)willMoveToSuperview:(UIView *)newSuperview {
|
|
|
+ [super willMoveToSuperview:newSuperview];
|
|
|
+
|
|
|
+ if (newSuperview) {
|
|
|
+ self.center = CGPointMake(newSuperview.bounds.size.width * 0.5, newSuperview.bounds.size.height * 0.5);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+- (void)layoutSubviews {
|
|
|
+ [super layoutSubviews];
|
|
|
+
|
|
|
+ if (self.superview) {
|
|
|
+ self.center = CGPointMake(self.superview.bounds.size.width * 0.5, self.superview.bounds.size.height * 0.5);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+- (void)hide {
|
|
|
+ [self removeFromSuperview];
|
|
|
+}
|
|
|
+
|
|
|
+@end
|
|
|
+
|
|
|
+@interface DetailPageViewController () <QLPreviewControllerDataSource,QLPreviewControllerDelegate,DetailKVCellTapDelegate>
|
|
|
|
|
|
@property (nonatomic,strong) QLPreviewController *quickLook;
|
|
|
@property (nonatomic,copy) NSString *documentPath;
|
|
|
@@ -444,6 +526,14 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+- (void)copyTap:(UITapGestureRecognizer *)tap {
|
|
|
+ UILabel *lb = (UILabel *)tap.view;
|
|
|
+
|
|
|
+ UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
|
|
|
+ pasteboard.string = lb.text;
|
|
|
+ [DetailHUD show:[NSString stringWithFormat:@"%@ Copied",lb.text] inView:self.view];
|
|
|
+}
|
|
|
+
|
|
|
#pragma mark - Table view data source
|
|
|
//
|
|
|
//- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
|
|
|
@@ -717,6 +807,12 @@
|
|
|
[btn addTarget:self action:@selector(sectionSwitchClick:) forControlEvents:UIControlEventTouchUpInside];
|
|
|
|
|
|
[header addSubview:btn];
|
|
|
+
|
|
|
+ // Tap Copy
|
|
|
+ UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(copyTap:)];
|
|
|
+ tapGesture.numberOfTapsRequired = 2;
|
|
|
+ [titleLb addGestureRecognizer:tapGesture];
|
|
|
+ titleLb.userInteractionEnabled = YES;
|
|
|
}
|
|
|
|
|
|
return header;
|
|
|
@@ -855,6 +951,8 @@
|
|
|
|
|
|
NSLog(@"key %@ val %@",key,val);
|
|
|
|
|
|
+ cell.tapDelegate = self;
|
|
|
+
|
|
|
// UIView * lineview = [[LineView alloc] initWithFrame:cell.contentView.frame];
|
|
|
// lineview.userInteractionEnabled = NO;// 不设为NO会屏蔽cell的点击事件
|
|
|
// lineview.backgroundColor = [UIColor clearColor];// 设为透明从而使得cell.backgroundColor有效.
|
|
|
@@ -1074,5 +1172,15 @@
|
|
|
return NO;
|
|
|
}
|
|
|
|
|
|
+#pragma mark - KVDetail Tap Delegate
|
|
|
+
|
|
|
+- (void)detailCell:(DetailCellKVNew *)cell doubleTapedForValue:(NSString *)value {
|
|
|
+
|
|
|
+// NSIndexPath *indexPath = [self.table indexPathForCell:cell];
|
|
|
+ UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
|
|
|
+ pasteboard.string = value;
|
|
|
+ [DetailHUD show:[NSString stringWithFormat:@"%@ Copied",cell.keyLabel.text] inView:self.view];
|
|
|
+
|
|
|
+}
|
|
|
|
|
|
@end
|