Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 如何使文本字段移动_Iphone_Objective C - Fatal编程技术网

Iphone 如何使文本字段移动

Iphone 如何使文本字段移动,iphone,objective-c,Iphone,Objective C,当我按下它时,我可以在视野中自由改变位置 -(iAction)添加:(id)发件人{ }首先将手势识别器添加到ViewDidLoad,然后创建函数 或者最好看看这里 我想拖动这个文本字段 (无效)viewDidLoad{ self.navigationItem.rightBarButtonItem=[[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarbuttonSystemAddTarget:self-action:@selec

当我按下它时,我可以在视野中自由改变位置

-(iAction)添加:(id)发件人{


}

首先将手势识别器添加到ViewDidLoad,然后创建函数
或者最好看看这里


我想拖动这个文本字段

  • (无效)viewDidLoad{
self.navigationItem.rightBarButtonItem=[[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarbuttonSystemAddTarget:self-action:@selector(add:)]autorelease]

}

-(iAction)添加:(id)发件人{


}

您能否详细阐述您的问题,并举例说明。还显示到目前为止您已尝试的内容。是否要拖动文本字段?是的,我要拖动文本字段textField@PasstissiPhone不是没有discription@Seega在非结构或结构中请求成员中心union@PasstissiPhone
textfield to add.center
common如果要移动文本字段,这个小错误你应该解决yourself@PasstissiPhone没有人会帮助你,如果你不解释你的问题,但是我的代码有什么问题?发生了什么和没有发生什么?
CGRect frame = CGRectMake(kLeftMargin, 8.0, kTextFieldWidth, kTextFieldHeight);

UITextField * textfieldToAdd = [[[UITextField alloc] initWithFrame:frame] autorelease];






        textfieldToAdd.borderStyle =  UITextBorderStyleRoundedRect; 
        textfieldToAdd.textColor = [UIColor blackColor];

        textfieldToAdd.font = [UIFont systemFontOfSize:17.0];
        textfieldToAdd.placeholder = @"";
        textfieldToAdd.backgroundColor = [UIColor whiteColor];
        textfieldToAdd.autocorrectionType = UITextAutocorrectionTypeNo ; // no auto correction support

        textfieldToAdd.keyboardType = UIKeyboardTypeDefault;   // use the default type input method (entire keyboard)
        textfieldToAdd.returnKeyType = UIReturnKeyDone;

        textfieldToAdd.clearButtonMode = UITextFieldViewModeWhileEditing;  // has a clear 'x' button to the right

        textfieldToAdd.tag = kViewTag;     // tag this control so we can remove it later for recycled cells

        textfieldToAdd.delegate = self;    // let us be the delegate so we know when the keyboard's "Done" button is pressed

        // Add an accessibility label that describes what the text field is for.
        [textfieldToAdd setAccessibilityLabel:NSLocalizedString(@"textfieldToAdd", @"")];



[self.view addSubview:textfieldToAdd];
UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panPiece:)];
[panGesture setMaximumNumberOfTouches:2];
[panGesture setDelegate:self];
[self addGestureRecognizer:panGesture];

- (void)panPiece:(UIPanGestureRecognizer *)gestureRecognizer
{
    if ([gestureRecognizer state] == UIGestureRecognizerStateBegan || [gestureRecognizer     state] == UIGestureRecognizerStateChanged) {
        CGPoint translation = [gestureRecognizer translationInView:self.view];
        textfieldToAdd.center = CGPointMake([self center].x + translation.x, [self center].y + translation.y);
        [gestureRecognizer setTranslation:CGPointZero inView:[self superview]];
    }
}
CGRect frame = CGRectMake(kLeftMargin, 8.0, kTextFieldWidth, kTextFieldHeight);

UITextField * textfieldToAdd = [[[UITextField alloc] initWithFrame:frame] autorelease];






        textfieldToAdd.borderStyle =  UITextBorderStyleRoundedRect; 
        textfieldToAdd.textColor = [UIColor blackColor];

        textfieldToAdd.font = [UIFont systemFontOfSize:17.0];
        textfieldToAdd.placeholder = @"";
        textfieldToAdd.backgroundColor = [UIColor whiteColor];
        textfieldToAdd.autocorrectionType = UITextAutocorrectionTypeNo ; // no auto correction support

        textfieldToAdd.keyboardType = UIKeyboardTypeDefault;   // use the default type input method (entire keyboard)
        textfieldToAdd.returnKeyType = UIReturnKeyDone;

        textfieldToAdd.clearButtonMode = UITextFieldViewModeWhileEditing;  // has a clear 'x' button to the right

        textfieldToAdd.tag = kViewTag;     // tag this control so we can remove it later for recycled cells
        textfieldToAdd.delegate = self;    // let us be the delegate so we know when the keyboard's "Done" button is pressed

        // Add an accessibility label that describes what the text field is for.
        [textfieldToAdd setAccessibilityLabel:NSLocalizedString(@"textfieldToAdd", @"")];





[self.view addSubview:textfieldToAdd];