我有以下问题.我正在使用一个UILongPressGestureRecognizerUIView进入"切换模式".如果UIView处于"切换模式",则用户可以在屏幕上拖动UIView.为了在屏幕上拖动UIView我正在使用方法touchesBegan,touchesMoved和touchesEnded.
它工作,但是:我必须举起手指才能拖动它,因为该touchesBegan方法已被调用,因此不会再次调用,因此我无法拖动UIView屏幕.
触发touchesBegan后是否有任何方法可以手动调用UILongPressGestureRecognizer(UILongPressGestureRecognizer更改BOOL值,touchesBegan仅当此BOOL设置为YES时才有效).
我有一个问题,关于在标题提到的方法中的迅速实施.如果我这样做:
leadingSpaceConstraint.constant = 0
UIView.animateWithDuration(0.3, animations: {
self.view.layoutIfNeeded()
}, completion: { (complete: Bool) in
self.navigationController.returnToRootViewController(true)
})
Run Code Online (Sandbox Code Playgroud)
我遇到以下问题:在调用中缺少参数'delay'的参数.只有在完成部分中有self.navigationController.returnToRootViewController()时才会发生这种情况.如果我将该语句提取为一个单独的方法,如下所示:
leadingSpaceConstraint.constant = 0
UIView.animateWithDuration(0.3, animations: {
self.view.layoutIfNeeded()
}, completion: { (complete: Bool) in
self.returnToRootViewController()
})
func returnToRootViewController() {
navigationController.popToRootViewControllerAnimated(true)
}
Run Code Online (Sandbox Code Playgroud)
然后它完美地工作,完全符合我的要求.当然,这似乎不是理想的解决方案,更像是一种解决方案.任何人都可以告诉我我做错了什么或为什么Xcode(beta 6)这样做?
正如标题中所写,我有一个属性UITextField.我把它UITextField加到了UIView.
如果我有一个强大的指针,UITextField出现,
如果我有一个弱指针,UITextField则不会出现.
当我有一个弱指针时出了什么问题?我做了同样的UIButton事情,然后它实际上出现(强指针和弱指针).
这是一些代码:
CreateCategoryView.h
@interface CreateCategoryView : UIView
@property (weak, nonatomic) UITextField *nameTextField;
@end
Run Code Online (Sandbox Code Playgroud)
CreateCategoryView.m
@implementation CreateCategoryView
- (id)initWithFrame:(CGRect)frame andParent {
self = [super initWithFrame:frame];
if (self) {
self.nameTextField = [[UITextField alloc] initWithFrame:CGRectMake(5, 30, 310, 25)];
self.nameTextField.borderStyle = UITextBorderStyleRoundedRect;
self.nameTextField.textColor = [UIColor blackColor];
self.nameTextField.backgroundColor = [UIColor whiteColor];
[self addSubview:self.nameTextField];
}
return self;
}
@end
Run Code Online (Sandbox Code Playgroud)