标签: uitextfield

无法设置UIKeyboard附件视图

我有一个UIToolbar包含UITextField内部的实例.我想将工具栏设置为UITextField它包含的附件视图.

我这样做的方式如下:

[myTextView setInputAccessoryView:myToolbar];
Run Code Online (Sandbox Code Playgroud)

当我编译并运行代码时,当我按下文本字段时,整个键盘都会消失.我特别确定我设定的inputAccessoryView而不是inputView.似乎整个输入视图都被替换了,没有任何明确的指示.

有谁知道解决这个问题的方法?

uitextfield uikit uikeyboard ios ios5

0
推荐指数
1
解决办法
2716
查看次数

从textFieldDidEndEditing调用reloadData后,对UITableView的indexPath不正确

因此,我正在尝试模拟管理电话号码时标准Apple代码在联系人应用上的工作方式.具体来说,我正在努力从tableview中删除一行,如果它是空的并且用户导航到任何其他行

我的问题是,当tableview重新加载导致UITextField重新签名其响应者时,我需要再次为用户导航到的文本字段设置响应者

我有UITextField委托,我正常处理 textFieldShouldBeginEditing , textFieldDidBeginEditing , textFieldShouldEndEditing , textFieldDidEndEditing

为了处理这个功能,我的代码就在textFieldDidEndEditing其中,我从tableview数组中删除了数据,并且由于tableview有2个部分,我正在调用:

[MyTableView reloadSections:[NSIndexSet indexSetWithIndex:1] withRowAnimation:UITableViewRowAnimationNone];
Run Code Online (Sandbox Code Playgroud)

textFieldDidBeginEditing我使用以下命令保存正在编辑的textField的indexPath 期间:

EditableCustomCell *textFieldCell = (EditableCustomCell *)[[textField superview] superview];
NSIndexPath *indexPath = [MyTableView indexPathForCell:(EditableCustomCell *)textFieldCell];
responderIndexPath = [NSIndexPath indexPathForRow:indexPath.row inSection:indexPath.section];
Run Code Online (Sandbox Code Playgroud)

然后我使用以下代码将正确的行textField设置为第一个响应者:

EditableCustomCell *customCell = (EditableCustomCell *)[MyTableView cellForRowAtIndexPath:responderIndexPath];
[customCell.editableTextField becomeFirstResponder];
Run Code Online (Sandbox Code Playgroud)

一切似乎都很好,直到接近处理结束时,突然textFieldDidBeginEditing开始返回第0行第0行的indexPath(即使在检查标记值或包含的文本时返回文本字段的正确值)

以下是上述过程开始时的日志:

- textFieldDidEndEditing started  <-- start of delete processing
- textFieldDidEndEditing - tableviewData - replacing object at index 1
    CustomTableViewController.deleteRow - delete called for indexPath section 1 ... row …
Run Code Online (Sandbox Code Playgroud)

objective-c uitableview uitextfield nsindexpath becomefirstresponder

0
推荐指数
1
解决办法
1234
查看次数

如何在cocos2d v2上使用CCTextField或添加UITextField

我目前正在尝试在cocos2d v2图层上永久显示TextField.

我正在使用这个CCTextField,因为它看起来很容易使用:https://github.com/iNinja/CCTextField

这个插件对于cocos2d v2有点旧,所以我更新了已弃用的方法,但我仍然无法显示任何文本字段...

我怎么想用cocos2d v2显示一个文本字段(任何方法都可以,只要它足够清晰且易于使用).

顺便说一句,我看了谷歌,并在stackoverflow和论坛上得到了2-3个答案.但是,它们适用于cocos2d v1(或更早版本),并且根本不起作用(或者不够清晰).

编辑

这就是我在班级的onEnter函数中所拥有的

 UITextField *tf = [[UITextField alloc] initWithFrame:CGRectMake(200, 200, 150, 50)];
tf.delegate = self;
tf.textAlignment = UITextAlignmentLeft;

[[[CCDirector sharedDirector] view] addSubview:tf];
Run Code Online (Sandbox Code Playgroud)

这就是.h

@interface AdventureLayer : CCLayer <UITextFieldDelegate>
Run Code Online (Sandbox Code Playgroud)

什么都没有出现......

编辑2

哈哈哈!实际上TextField是不可见的!因此占位符非常有用

 tf.placeholder = @"FOOBAR";
Run Code Online (Sandbox Code Playgroud)

iphone uitextfield cocos2d-iphone ios

0
推荐指数
1
解决办法
3920
查看次数

UITextField Delegate无法正常工作

我有以下代码:

@interface MyCell : UITableViewCell<UITextFieldDelegate>
{
    IBOutlet UITextField *txtFields;
}

- (IBAction)textFieldAction:(id)sender;
@property (nonatomic,retain) IBOutlet UITextField *txtFields;

@end
Run Code Online (Sandbox Code Playgroud)

我还有以下委托功能:

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
    return NO;
}
Run Code Online (Sandbox Code Playgroud)

但是,我注意到它永远不会被召唤.我从接口构建器以及代码中设置委托:[txtFields setDelegate:self];但似乎都不起作用.我还缺少其他的东西吗?

uitextfield ios uitextfielddelegate

0
推荐指数
1
解决办法
1725
查看次数

如何使用新的iOS 6方法将文本居中?

我的旧代码

sectorLabel.textAlignment = UITextAlignmentCenter;
Run Code Online (Sandbox Code Playgroud)

Xcode表示不推荐使用textAlignment.我如何使用新方法?

谢谢

text-alignment uitextfield uilabel ios

0
推荐指数
1
解决办法
1740
查看次数

在UITableViewCell中安装UITextField而不用硬编码文本字段的框架?

在UITableViewCell中有一个UITextField

我正在使用表格视图制作填写表格(名字,中间名,姓氏),并希望在我的一些单元格中嵌入文本字段.我看到很多关于在UITableViewCell中添加UITextField的例子,如上所述.但是,它们都具有文本字段框架的硬编码值,如下所示

UITextField *playerTextField = [[UITextField alloc] initWithFrame:CGRectMake(110, 10, 185, 30)];
Run Code Online (Sandbox Code Playgroud)

我希望我的文本字段使用单元格的框架或边界.

为了使事情变得更有趣,我的表视图有四个部分,只有第1部分(有3行)将嵌入文本字段.

为了使事情更有趣,我使用弹出控制器来呈现我的表单.

那么,在设置框架或边界时,如何在不使用硬编码值的情况下嵌入我的文本字段以适合我的表格视图单元格?

谢谢!

uitableview uitextfield ios

0
推荐指数
1
解决办法
3911
查看次数

无法更改UISearchbar文本字段的大小

我有一个被UISearchBar创建的InterfaceBuilderIBOutlet被称为userSearchBar.现在我想在代码中改变它的宽度和高度而不能这样做.这是我的代码:

    for (UIView * const subview in userSearchBar.subviews) {

    if ([subview isKindOfClass: NSClassFromString(@"UISearchBarBackground")]) {
        [subview removeFromSuperview];
    }

    if ([subview isKindOfClass: [UITextField class]]) {

        UITextField * const textField = (UITextField *)subview;

        textField.textColor = [UIColor redColor];
        textField.text = @"Enter text";
        textField.frame = CGRectMake(0, 0, 250, 50);
    }
}
Run Code Online (Sandbox Code Playgroud)

所有其他更改(文本,颜色,删除栏)工作完美但不改变大小.

objective-c uitextfield uisearchbar ios

0
推荐指数
1
解决办法
1630
查看次数

Uipicker取代键盘

好的,我正在尝试用UIpicker替换键盘.我得到了代码,Uipicker总是显示,当你点击文本字段时,当然键盘出现....我甚至把断点放进去看看它是否代表它告诉它隐藏了键盘,它永远不会....有人看着它,看看我哪里出错了

 #import "collectionViewViewController.h"
#import "activityCell.h"

@interface collectionViewViewController ()
{
    NSArray *imageArray;
    NSArray *labelArray;
}

@end

@implementation collectionViewViewController
@synthesize pickerViewContainer;


- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}



- (void)viewDidLoad
{
    [super viewDidLoad];

    //picker exists in the view, but is outside visible range
    UIPickerView *pickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(200, 780, 400, 270)];
    pickerView.delegate = self;
    pickerView.showsSelectionIndicator = YES;
    [self.view addSubview:pickerView];



    [[self collectionView]setDataSource:self];
    [[self collectionView]setDelegate:self];

    imageArray = [[NSArray alloc]initWithObjects: …
Run Code Online (Sandbox Code Playgroud)

keyboard xcode replace uitextfield uipicker

0
推荐指数
1
解决办法
1709
查看次数

在iOS中使用NSNumberFormatter进行货币转换时遇到问题

我有一个UITextField,它接收我的应用程序中用户的数字输入.然后,在我的shouldChangeCharactersInRange委托方法中,使用NSNumberFormatter将此文本字段中的值转换为货币格式.当我输入数字"12345678"时,数字被正确转换为$ 123456.78(数字一次输入一位数,到目前为止,一切顺利).但是,当我在此之后输入另一个数字(例如9),而不是显示"1234567.89"时,会显示数字"1234567.88".如果我之后输入另一个数字,之后会有一个完全不同的数字(我在应用程序中使用数字键盘输入数字.这是我的代码:

NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
[formatter setNumberStyle:NSNumberFormatterCurrencyStyle];
modifiedValue = [formatter stringFromNumber:[NSNumber numberWithFloat:[modifiedValue floatValue]]];
textField.text = modifiedValue;
Run Code Online (Sandbox Code Playgroud)

导致这种异常转换的行是这样的:

modifiedValue = [formatter stringFromNumber:[NSNumber numberWithFloat:[modifiedValue floatValue]]];
Run Code Online (Sandbox Code Playgroud)

谁能明白为什么会这样?

uitextfield nsnumberformatter ios uitextfielddelegate

0
推荐指数
1
解决办法
4055
查看次数

从nsmutable数组中删除对象

我通过按钮操作在数组中逐个添加数组中的文本字段,同样我想从最后一个一个一个地删除另一个按钮中的这些文本字段,我该怎么办我使用此代码添加

- (IBAction)btnAddTxtField:(id)sender {
   // [self buttonPressed];
//    currentIndex =0;
//    
//    int x = 132;
//    int y = 550;
//    

//   
//    UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake((currentIndex % 1) * x + 45, (currentIndex / 1) * y + 28, 214, 25)];
//    
//    
    textField = [[UITextField alloc] initWithFrame:CGRectMake(76, ([txtFieldArray count] * 30), 191, 25)];
    [textField setBorderStyle:UITextBorderStyleLine];
    textField.font = [UIFont systemFontOfSize:20];
    textField.placeholder = @"Enter text";
    textField.autocorrectionType = UITextAutocorrectionTypeNo;
    textField.keyboardType = UIKeyboardTypeDefault;
    textField.returnKeyType = UIReturnKeyDone;
    textField.clearButtonMode = UITextFieldViewModeWhileEditing; …
Run Code Online (Sandbox Code Playgroud)

iphone xcode uitextfield nsmutablearray ios

0
推荐指数
1
解决办法
131
查看次数