質問するログイン新規登録

質問編集履歴

1

ソースコードを追記

2015/06/18 11:19

投稿

Satochan24
Satochan24

スコア114

title CHANGED
File without changes
body CHANGED
@@ -3,4 +3,156 @@
3
3
  textFieldShouldBeginEditingが認識されず、宣言されていないと怒られてしまいます。
4
4
  何か、理由ありますでしょうか?
5
5
  参考にしたサイト
6
- http://andbyyou.com/ios-uipickerview%E3%82%92uiactionsheet%E5%86%85%E3%81%AB%E5%87%BA%E3%81%99%E3%81%8B%E3%81%A4picker%E3%82%92%E8%A4%87%E6%95%B0%E8%A8%AD%E5%AE%9A/
6
+ http://andbyyou.com/ios-uipickerview%E3%82%92uiactionsheet%E5%86%85%E3%81%AB%E5%87%BA%E3%81%99%E3%81%8B%E3%81%A4picker%E3%82%92%E8%A4%87%E6%95%B0%E8%A8%AD%E5%AE%9A/
7
+
8
+
9
+ コードを貼ります。もともと、1画面内にピッカーを3つ配置していたのですが、試験的にActionシートでのピッカーを設置している内容です。
10
+ [CourseViewController.h]
11
+ ```lang-<#import <UIKit/UIKit.h>
12
+
13
+ @interface CourseViewController : UIViewController <UIPickerViewDelegate,UIPickerViewDataSource,UIActionSheetDelegate,UITextFieldDelegate>
14
+ {
15
+ // NSArray *bus_course; バスコースはサーバからの応答データを使用するため固定の値は使用しない。
16
+ NSArray *bus_ride_type;
17
+ NSArray *bus_measure_time_interval;
18
+ UIActionSheet *actionsheet;
19
+ }
20
+ @property (weak, nonatomic) IBOutlet UILabel *button_entry_label;
21
+ perty (nonatomic, strong) NSMutableArray *bus_course_mutable;
22
+ @property (nonatomic, strong) NSMutableArray *course_id_mutable;
23
+
24
+
25
+ - (IBAction)button_start:(UIButton *)sender;
26
+ - (IBAction)button_back:(UIButton *)sender;
27
+
28
+ @property (weak, nonatomic) IBOutlet UITextField *textField1;
29
+ @property (weak, nonatomic) IBOutlet UITextField *textField2;
30
+ @property (weak, nonatomic) IBOutlet UITextField *textField3;
31
+
32
+ @end>
33
+ コード
34
+ ```
35
+
36
+ [CourseViewController.m]
37
+ ```lang-<
38
+ #import "CourseViewController.h"
39
+ #import "GPSPositionViewController.h"
40
+
41
+ @interface CourseViewController ()
42
+
43
+ @property (weak, nonatomic) IBOutlet UIPickerView *picker;
44
+ @property (weak, nonatomic) IBOutlet UIPickerView *picker2;
45
+ @property (weak, nonatomic) IBOutlet UIPickerView *picker3;
46
+
47
+ @end
48
+
49
+ @implementation CourseViewController
50
+ {
51
+ // Action sheet test
52
+ UIPickerView *picker_1;
53
+ UIPickerView *picker_2;
54
+ UIPickerView *picker_3;
55
+
56
+ NSString *pic1_str;
57
+ NSString *pic2_str;
58
+ NSString *pic3_str;
59
+
60
+ }
61
+
62
+ // Action sheet test
63
+ @synthesize textField1;
64
+ @synthesize textField2;
65
+ @synthesize textField3;
66
+
67
+ - (void)viewDidLoad {
68
+ [super viewDidLoad];
69
+ // Do any additional setup after loading the view.
70
+
71
+
72
+ // パラメータ受け渡し
73
+ _textView_CsName.text = self.Cs_Name;
74
+ _textView_UserName.text = self.User_Name;
75
+ _Mode = self.Mode;
76
+
77
+ // 設定運行の処理
78
+ if ([_Mode isEqual: @"2"]) {
79
+ _button_entry_label.text = @"設定運行";
80
+ //_button_entry_label.textColor.redColor;
81
+ }
82
+
83
+
84
+ bus_ride_type = [NSArray arrayWithObjects:
85
+ @"登園",
86
+ @"降園", nil];
87
+ bus_measure_time_interval = [NSArray arrayWithObjects:
88
+ @"5",
89
+ @"10,nil];
90
+
91
+ _picker.delegate = self;
92
+ _picker2.delegate = self;
93
+ _picker3.delegate = self;
94
+ _picker.dataSource = self;
95
+ _picker2.dataSource = self;
96
+ _picker3.dataSource = self;
97
+
98
+ // Action sheet test
99
+ textField1.delegate = self;
100
+ textField2.delegate = self;
101
+ textField3.delegate = self;
102
+ textField1.tag = 1;
103
+ textField2.tag = 2;
104
+ textField3.tag = 3;
105
+
106
+ CGRect rect = [[UIScreen mainScreen] bounds];
107
+
108
+ picker_1 = [[UIPickerView alloc] init];
109
+ picker_1.frame = CGRectMake(0, rect.size.height, 320, 216);
110
+ picker_1.showsSelectionIndicator = YES;
111
+ picker_1.delegate = self;
112
+ picker_1.dataSource = self;
113
+ picker_1.tag = 1;
114
+ [self.view addSubview:picker_1];
115
+
116
+ picker_2 = [[UIPickerView alloc] init];
117
+ picker_2.frame = CGRectMake(0, rect.size.height, 320,216);
118
+ picker_2.showsSelectionIndicator = YES;
119
+ picker_2.delegate = self;
120
+ picker_2.dataSource = self;
121
+ picker_2.tag = 2;
122
+ [self.view addSubview:picker_2];
123
+
124
+ picker_3 = [[UIPickerView alloc] init];
125
+ picker_3.frame = CGRectMake(0, rect.size.height, 320,216);
126
+ picker_3.showsSelectionIndicator = YES;
127
+ picker_3.delegate = self;
128
+ picker_3.dataSource = self;
129
+ picker_3.tag = 2;
130
+ [self.view addSubview:picker_3];
131
+
132
+
133
+ // Action sheet test
134
+ - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
135
+ CGRect rect = [[UIScreen mainScreen] bounds];
136
+ if (textField.tag == 1) {
137
+ NSLog(@"1");
138
+ picker2.frame = CGRectMake(0, rect.size.height, 320, 216);
139
+ [self showPicker1]; //picker1を表示させるメソッドを実行
140
+ //キーボードは表示させない
141
+ return NO;
142
+ }
143
+ if (textField.tag == 2) {
144
+ NSLog(@"2");
145
+ picker1.frame = CGRectMake(0, rect.size.height, 320, 216);
146
+ [self showPicker2]; //picker2を表示させるメソッドを実行
147
+ //キーボードは表示させない
148
+ return NO;
149
+ }
150
+ return NO;
151
+ }
152
+
153
+
154
+ }
155
+
156
+ @end>
157
+ コード
158
+ ```