为什么你需要在你的类中包含一个构造函数public static void main (String[] args){}?
为什么不使用构造函数单独的类并实例化它?
我正在使用UIPicker来填充UITextField而不是键盘.这很好但我现在无法关闭UIPicker.我希望能够点击屏幕上的任意位置并关闭UIPicker.我已经尝试过每一个触摸方法,一个无法触发.
setUserInteractionEnabled:YES.不确定它是否有所作为,但我正在使用StoryBoard
我应该在我的AppDelegate中设置一些内容来监听触摸吗?
这是我的.h
#import <UIKit/UIKit.h>
@interface RNMemberTableViewController : UITableViewController<UIPickerViewDataSource, UIPickerViewDelegate, UITextFieldDelegate>
@property (weak, nonatomic) IBOutlet UIPickerView *behaviorPicker;
@property (nonatomic, weak) IBOutlet UIDatePicker *dateOfRecordPicker;
@property (nonatomic, strong) NSArray *behaviorLevels;
@property (weak, nonatomic) IBOutlet UITextField *behaviorTextField;
@end
Run Code Online (Sandbox Code Playgroud)
这里有一些实施......
- (void)viewDidLoad
{
[super viewDidLoad];
[self.view setUserInteractionEnabled:YES];
[self buildBehaviorPicker];
NSLog(@"Member View");
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
NSLog(@"test");
[self.view touchesBegan:touches withEvent:event];
UITouch *touch = [touches anyObject];
int tCount = touch.tapCount;
NSLog(@"Touched %d", tCount);
}
- (void) buildBehaviorPicker
{
behaviorLevels = [[NSArray alloc] …Run Code Online (Sandbox Code Playgroud)