相关疑难解决方法(0)

UITextField的文本插入?

我想插页的文字UITextField.

这可能吗?

cocoa-touch uitextfield ios

402
推荐指数
20
解决办法
19万
查看次数

UITextField中的缩进

例如,我希望

UITextView缩进问题:

例如,我希望"测试"文本有点正确,我应该设置什么属性?

xcode objective-c indentation uitextfield ios

5
推荐指数
2
解决办法
4133
查看次数

UITextField - 为leftView添加UIView - 无法获得Focus

我的应用程序中的UITextFields定义了占位符文本(在Interface Builder中),当我点击占位符文本占用的区域时,我无法使这些字段获得焦点(即显示键盘并允许编辑).如果我点击占位符文本之外的区域中的文本字段(尽管仍然在文本文本本身的范围内),它会正常运行(即弹出键盘,我可以编辑文本字段的内容).我怎样才能解决这个问题?

谢谢.

编辑1

好的,我想我已经知道了.我还设置了这些UITextFields的"leftView"属性的空白视图.如果我删除它,你可以触摸占位符文本区域中的UITextFields,它会按预期做出反应; 我需要这个视图为leftView.如果您将此间隔视图的背景颜色更改为红色,您可以看到它根本不会妨碍,所以我不知道出了什么问题.

为什么这段代码会导致这个问题?

谢谢.

+(UIView*)getTextFieldLeftSpacerViewWithBackgroundColor:(UIColor*)backgroundColor andHeight:(CGFloat)height
{
    UIView *leftWrapper = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 8.0f, height)];
    leftWrapper.autoresizingMask = UIViewAutoresizingNone;
    [leftWrapper setOpaque:YES];
    if(backgroundColor){leftWrapper.backgroundColor = backgroundColor;}
    else{leftWrapper.backgroundColor = [UIColor clearColor];}
    return [leftWrapper autorelease];
}

+(void)setTextFieldLeftSpacerForTextFieled:(UITextField*)textField
{
    if(textField)
    {
        UIView *spacer = [MYViewController getTextFieldLeftSpacerViewWithBackgroundColor:nil andHeight:textField.bounds.size.height];
        textField.leftView = spacer;
        textField.leftViewMode = UITextFieldViewModeAlways;
    }
}
Run Code Online (Sandbox Code Playgroud)

objective-c interface-builder uitextfield ios

3
推荐指数
1
解决办法
3023
查看次数