|
6 | 6 | // |
7 | 7 |
|
8 | 8 | #import "TapDBViewController.h" |
| 9 | +#import <TapSDK/TapDB.h> |
9 | 10 |
|
10 | 11 | @interface TapDBViewController () |
| 12 | +@property (nonatomic, strong) UILabel *nameLabel; |
| 13 | +@property (nonatomic, strong) UILabel *levelLabel; |
| 14 | +@property (nonatomic, strong) UILabel *serverLabel; |
| 15 | +@property (nonatomic, strong) UILabel *chargeLabel; |
| 16 | +@property (nonatomic, strong) UILabel *eventLabel; |
11 | 17 |
|
| 18 | +@property (nonatomic, strong) UITextField *nameText; |
| 19 | +@property (nonatomic, strong) UITextField *levelText; |
| 20 | +@property (nonatomic, strong) UITextField *serverText; |
| 21 | + |
| 22 | +@property (nonatomic, strong) UIButton *nameButton; |
| 23 | +@property (nonatomic, strong) UIButton *levelButton; |
| 24 | +@property (nonatomic, strong) UIButton *serverButton; |
| 25 | +@property (nonatomic, strong) UIButton *chargeButton; |
| 26 | +@property (nonatomic, strong) UIButton *eventButton; |
12 | 27 | @end |
13 | 28 |
|
14 | 29 | @implementation TapDBViewController |
15 | 30 |
|
16 | 31 | - (void)viewDidLoad { |
17 | 32 | [super viewDidLoad]; |
| 33 | + self.view.backgroundColor = [UIColor whiteColor]; |
| 34 | + [self.view addSubview:self.nameLabel]; |
| 35 | + [self.view addSubview:self.levelLabel]; |
| 36 | + [self.view addSubview:self.serverLabel]; |
| 37 | + [self.view addSubview:self.chargeLabel]; |
| 38 | + [self.view addSubview:self.eventLabel]; |
| 39 | + |
| 40 | + [self.view addSubview:self.nameText]; |
| 41 | + [self.view addSubview:self.levelText]; |
| 42 | + [self.view addSubview:self.serverText]; |
| 43 | + |
| 44 | + [self.view addSubview:self.nameButton]; |
| 45 | + [self.view addSubview:self.levelButton]; |
| 46 | + [self.view addSubview:self.serverButton]; |
| 47 | + [self.view addSubview:self.chargeButton]; |
| 48 | + [self.view addSubview:self.eventButton]; |
| 49 | +} |
| 50 | + |
| 51 | +- (UILabel *)nameLabel { |
| 52 | + if (!_nameLabel) { |
| 53 | + _nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 50, 20)]; |
| 54 | + _nameLabel.text = @"name"; |
| 55 | + } |
| 56 | + return _nameLabel; |
| 57 | +} |
| 58 | + |
| 59 | +- (UILabel *)levelLabel { |
| 60 | + if (!_levelLabel) { |
| 61 | + _levelLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 60, 50, 20)]; |
| 62 | + _levelLabel.text = @"level"; |
| 63 | + } |
| 64 | + return _levelLabel; |
| 65 | +} |
| 66 | + |
| 67 | +- (UILabel *)serverLabel { |
| 68 | + if (!_serverLabel) { |
| 69 | + _serverLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 110, 50, 20)]; |
| 70 | + _serverLabel.text = @"server"; |
| 71 | + } |
| 72 | + return _serverLabel; |
| 73 | +} |
| 74 | + |
| 75 | +- (UILabel *)chargeLabel { |
| 76 | + if (!_chargeLabel) { |
| 77 | + _chargeLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 160, 50, 20)]; |
| 78 | + _chargeLabel.text = @"chargr"; |
| 79 | + } |
| 80 | + return _chargeLabel; |
| 81 | +} |
| 82 | + |
| 83 | +- (UILabel *)eventLabel { |
| 84 | + if (!_eventLabel) { |
| 85 | + _eventLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 210, 50, 20)]; |
| 86 | + _eventLabel.text = @"event"; |
| 87 | + } |
| 88 | + return _eventLabel; |
| 89 | +} |
| 90 | + |
| 91 | +- (UITextField *)nameText { |
| 92 | + if (!_nameText) { |
| 93 | + _nameText = [[UITextField alloc] initWithFrame:CGRectMake(80, 10, 100, 20)]; |
| 94 | + _nameText.text = @"nameTest"; |
| 95 | + _nameText.backgroundColor = [UIColor lightGrayColor]; |
| 96 | + } |
| 97 | + return _nameText; |
| 98 | +} |
| 99 | + |
| 100 | +- (UITextField *)levelText { |
| 101 | + if (!_levelText) { |
| 102 | + _levelText = [[UITextField alloc] initWithFrame:CGRectMake(80, 60, 100, 20)]; |
| 103 | + _levelText.text = @"1"; |
| 104 | + _levelText.backgroundColor = [UIColor lightGrayColor]; |
| 105 | + } |
| 106 | + return _levelText; |
| 107 | +} |
| 108 | + |
| 109 | +- (UITextField *)serverText { |
| 110 | + if (!_serverText) { |
| 111 | + _serverText = [[UITextField alloc] initWithFrame:CGRectMake(80, 110, 100, 20)]; |
| 112 | + _serverText.text = @"serverTest"; |
| 113 | + _serverText.backgroundColor = [UIColor lightGrayColor]; |
| 114 | + } |
| 115 | + return _serverText; |
| 116 | +} |
| 117 | + |
| 118 | +- (UIButton *)nameButton { |
| 119 | + if (!_nameButton) { |
| 120 | + _nameButton = [[UIButton alloc] initWithFrame:CGRectMake(200, 10, 100, 20)]; |
| 121 | + [_nameButton setTitle:@"set Name" forState:UIControlStateNormal]; |
| 122 | + _nameButton.layer.cornerRadius = 5; |
| 123 | + _nameButton.layer.masksToBounds = YES; |
| 124 | + _nameButton.backgroundColor = [UIColor colorWithRed:0.08 green:0.73 blue:0.78 alpha:1.00]; |
| 125 | + [_nameButton addTarget:self action:@selector(nameButtonAction) forControlEvents:UIControlEventTouchUpInside]; |
| 126 | + } |
| 127 | + return _nameButton; |
| 128 | +} |
| 129 | + |
| 130 | +- (UIButton *)levelButton { |
| 131 | + if (!_levelButton) { |
| 132 | + _levelButton = [[UIButton alloc] initWithFrame:CGRectMake(200, 60, 100, 20)]; |
| 133 | + [_levelButton setTitle:@"set Level" forState:UIControlStateNormal]; |
| 134 | + _levelButton.layer.cornerRadius = 5; |
| 135 | + _levelButton.layer.masksToBounds = YES; |
| 136 | + _levelButton.backgroundColor = [UIColor colorWithRed:0.08 green:0.73 blue:0.78 alpha:1.00]; |
| 137 | + [_levelButton addTarget:self action:@selector(levelButtonAction) forControlEvents:UIControlEventTouchUpInside]; |
| 138 | + } |
| 139 | + return _levelButton; |
| 140 | +} |
| 141 | + |
| 142 | +- (UIButton *)serverButton { |
| 143 | + if (!_serverButton) { |
| 144 | + _serverButton = [[UIButton alloc] initWithFrame:CGRectMake(200, 110, 100, 20)]; |
| 145 | + [_serverButton setTitle:@"set Server" forState:UIControlStateNormal]; |
| 146 | + _serverButton.layer.cornerRadius = 5; |
| 147 | + _serverButton.layer.masksToBounds = YES; |
| 148 | + _serverButton.backgroundColor = [UIColor colorWithRed:0.08 green:0.73 blue:0.78 alpha:1.00]; |
| 149 | + [_serverButton addTarget:self action:@selector(serverButtonAction) forControlEvents:UIControlEventTouchUpInside]; |
| 150 | + } |
| 151 | + return _serverButton; |
| 152 | +} |
| 153 | + |
| 154 | +- (UIButton *)chargeButton { |
| 155 | + if (!_chargeButton) { |
| 156 | + _chargeButton = [[UIButton alloc] initWithFrame:CGRectMake(200, 160, 100, 20)]; |
| 157 | + [_chargeButton setTitle:@"on Charge" forState:UIControlStateNormal]; |
| 158 | + _chargeButton.layer.cornerRadius = 5; |
| 159 | + _chargeButton.layer.masksToBounds = YES; |
| 160 | + _chargeButton.backgroundColor = [UIColor colorWithRed:0.08 green:0.73 blue:0.78 alpha:1.00]; |
| 161 | + [_chargeButton addTarget:self action:@selector(chargeButtonAction) forControlEvents:UIControlEventTouchUpInside]; |
| 162 | + } |
| 163 | + return _chargeButton; |
| 164 | +} |
| 165 | + |
| 166 | +- (UIButton *)eventButton { |
| 167 | + if (!_eventButton) { |
| 168 | + _eventButton = [[UIButton alloc] initWithFrame:CGRectMake(200, 210, 100, 20)]; |
| 169 | + [_eventButton setTitle:@"on Event" forState:UIControlStateNormal]; |
| 170 | + _eventButton.layer.cornerRadius = 5; |
| 171 | + _eventButton.layer.masksToBounds = YES; |
| 172 | + _eventButton.backgroundColor = [UIColor colorWithRed:0.08 green:0.73 blue:0.78 alpha:1.00]; |
| 173 | + [_eventButton addTarget:self action:@selector(eventButtonAction) forControlEvents:UIControlEventTouchUpInside]; |
| 174 | + } |
| 175 | + return _eventButton; |
| 176 | +} |
| 177 | + |
| 178 | +- (void)nameButtonAction{ |
| 179 | + [TapDB setName:self.nameText.text]; |
| 180 | +} |
| 181 | + |
| 182 | +- (void)levelButtonAction{ |
| 183 | + [TapDB setLevel:[self.levelText.text intValue]]; |
| 184 | +} |
| 185 | + |
| 186 | +- (void)serverButtonAction{ |
| 187 | + [TapDB setServer:self.serverText.text]; |
| 188 | +} |
| 189 | + |
| 190 | +- (void)chargeButtonAction{ |
| 191 | + [TapDB onChargeSuccess:@"22222" product:@"product2" amount:3 currencyType:@"rmb" payment:@"10"]; |
| 192 | +} |
18 | 193 |
|
| 194 | +- (void)eventButtonAction{ |
| 195 | + NSDictionary* dic = @{@"aaa":@"xxx",@"bbb":@"yyy"}; |
| 196 | + [TapDB onEvent:@"testEvent2" properties:dic]; |
19 | 197 | } |
20 | 198 |
|
21 | 199 | /* |
|
0 commit comments