2

アプリケーションを初めて起動したときに、テキストフィールドを編集不可にしたい。そして、私はそれをタップすることによってUIBarbuttonアイテムを持っています、それはテキストフィールドを編集可能にします。以下のコードを試していますが、機能していません。

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{
if(edit == NO){
   textField.enabled = NO;
}
    if(edit == YES){
    textField.enabled = NO;
  }
 return YES;}
4

8 に答える 8

2

この方法を使用する必要があります

-(Void)viewwillappers
 {
   [textfield setEnable:NO];
 }

クリックバーボタンの後、ボタンクリック方式でyesに設定します。

于 2012-05-02T06:09:52.197 に答える
2
txtfld.userInteractionEnabled = NO;
// perform changes and enable afterwards
txtfld.userInteractionEnabled = YES;
于 2012-05-02T07:14:25.130 に答える
2

これを試して

-(Void)viewwillapper

{

[textfield setuserintractionEnable:yes];

}
于 2012-05-02T07:16:58.470 に答える
2

- (void)viewWillAppear:(BOOL)animatedこれにはデリゲートを使用できます。

- (void)viewWillAppear:(BOOL)animated
 {
   [textfield setEnable:NO];
 }

[textfield setEnable:YES];そして、バーボタンのクリック方法を書いて、

- (IBAction)clicked:(id)sender
  {
    [textfield setEnable:YES];
  }

上記のコードを使用する場合、別のビュー(詳細ビュー)に移動して戻ってくると、textFieldも無効になります。それが不要な場合は、次のコードを使用してください。

 - (void)viewDidLoad
 {
  [textfield setEnable:NO];
 }

ビューコントローラデリゲートの詳細については、UIViewControllerクラスリファレンスを参照してください。

于 2012-07-05T18:45:51.040 に答える
1
- (UITableViewCell *)tableView:(UITableView *)tableView
     cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView
                         dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[[UITableViewCell alloc]
             initWithStyle:UITableViewCellStyleValue1
             reuseIdentifier:CellIdentifier]
            autorelease];
}
cell.textLabel.text=[Players objectAtIndex:indexPath.row];

playername=[[UITextField alloc]initWithFrame:CGRectMake(10, 3, 280, 30)];  
playername.placeholder=@"Player";
playername.delegate=self;
playername.keyboardType=UIKeyboardTypeDefault;
 // playername.returnKeyType=UIReturnKeyDone;
[cell.contentView addSubview:playername];
 return cell;
}

これを動的テキストフィールドに使用します。

于 2012-05-02T07:14:52.043 に答える
1

また、ストーリーボードを使用している場合は、TextFieldの[有効]チェックボックスをオフにするだけです。トリックを行う必要があります。

于 2016-03-29T18:33:20.713 に答える
0

単純。

XIBで、textrFieldのプロパティについて、「ユーザーインタラクションが有効」のチェックを外します

。バーボタンのクリックイベントで、これを使用します。

   [textfield setEnable:NO];

メリット:

このビューを再度ロードすると、最初はそのtextFieldが無効になります。

だからそれはあなたが望むようになります。

于 2012-05-02T06:48:20.610 に答える
0
- (UITableViewCell *)tableView:(UITableView *)tableView
     cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{
static NSString *MyIdentifier = @"tblCellView";

PlayerDetailsCell *cell = (PlayerDetailsCell *)[tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if(cell == nil) {
    [[NSBundle mainBundle] loadNibNamed:@"PlayerDetailsCell" owner:self options:nil];
    cell = tblCell;
}
return cell; 
}

テーブルビューでこのコードを使用して、uitableviewcellクラスを呼び出します。私が呼んでいるように(playerdetailscell)

于 2012-05-02T07:07:36.567 に答える