-
Notifications
You must be signed in to change notification settings - Fork 69
Expand file tree
/
Copy pathCustomWebView.m
More file actions
79 lines (60 loc) · 1.58 KB
/
Copy pathCustomWebView.m
File metadata and controls
79 lines (60 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//
// CustomWebView.m
// WebviewTest
//
// Created by admin on 16/9/13.
// Copyright © 2016年 admin. All rights reserved.
//
#import "CustomWebView.h"
@implementation CustomWebView
-(id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self)
{
// 全代码时入口
[self addMenu];
}
return self;
}
-(void)awakeFromNib
{
[super awakeFromNib];
// xib时入口
[self addMenu];
}
- (void)addMenu
{
UIMenuController *menuController = [UIMenuController sharedMenuController];
UIMenuItem *menuItemCopy = [[UIMenuItem alloc] initWithTitle:@"复制" action:@selector(copyT:)];
UIMenuItem *menuItemNote = [[UIMenuItem alloc] initWithTitle:@"笔记" action:@selector(noteT:)];
UIMenuItem *menuItemSearch = [[UIMenuItem alloc] initWithTitle:@"搜索" action:@selector(searchT:)];
UIMenuItem *menuItemShare = [[UIMenuItem alloc] initWithTitle:@"分享" action:@selector(shareT:)];
NSArray *mArray = [NSArray arrayWithObjects:menuItemCopy,menuItemNote,menuItemSearch,menuItemShare,nil];
[menuController setMenuItems:mArray];
}
-(BOOL)canPerformAction:(SEL)action withSender:(id)sender
{
if(action == @selector(copyT:) || action == @selector(noteT:) || action == @selector(searchT:) || action == @selector(shareT:))
{
return YES;
}
return NO;
}
-(void)copyT:(id)sender
{
NSLog(@"复制");
}
-(void)noteT:(id)sender
{
NSLog(@"笔记");
}
-(void)searchT:(id)sender
{
NSLog(@"搜索");
}
-(void)shareT:(id)sender
{
NSLog(@"分享");
}
@end