-(void)sendcomment:(UIButton *)sender{
NSLog(@" send commment server");
thirdviewcellTableViewCell *dja =[[thirdviewcellTableViewCell alloc] init];
NSString *vga = [[NSString alloc] init];
vga=dja.celltext;
NSLog(@"comment value is %@",vga);
NSLog(@"comment cell value is %@",dja.celltext);
}
-1
A
答えて
1
-(void)sendcomment:(UIButton *)sender
{
UIButton *button = (UIButton*)sender;
NSIndexPath *indexpath = [NSIndexPath indexPathForRow:sender.tag inSection:0];
UITableViewCell *cell = (UITableViewCell*)[tblView cellForRowAtIndexPath: indexpath];
// If you have text field
UITextField *textfiled = (UITextField *)[cell.contentView viewWithTag:yourtextfeildtagvlaue];
// NSString *vga = textfiled.text
}
0
電池はボタンを押した場合は、あなたがこれを行うことができます:
-(void)sendcomment:(UIButton *)sender{
// 1. get the position the button you clicked
CGPoint correctedPoint = [sender convertPoint:button.bounds.origin toView:self.tableView];
// 2. find the cell via the position
NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:correctedPoint];
thirdviewcellTableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];;
// 3. then you can get the TextField value
NSString *textFieldValue = [[NSString alloc] init];
textFieldValue = cell.celltext;
}
0
あなたがで
-(void)sendcomment:(UIButton *)sender
{
UIButton *button = (UIButton*)sender;
NSIndexPath *indexpath = [NSIndexPath indexPathForRow:sender.tag inSection:0];
UITableViewCell *cell = (UITableViewCell*)sender.superview.superview;// get cell using view hierarchy
// If you have text field
UITextField *textfiled = (UITextField *)[cell.contentView viewWithTag:yourtextfeildtagvlaue];
// NSString *vga = textfiled.text
}
*
0
セルの階層を使用してセルを取得あなたのアクションメソッドはあなたのTextFieldを以下のように見つけることができます: SuperPathからIndexPathを見つけることができます。 コードを参照してください。
UIView *superView = btn.superview;
while (![superView isKindOfClass:[UITableViewCell class]]) {
superView = superView.superview;
}
CustomCell *cell = (CustomCell *)superView;
あなたはcell.yourTextFeld
からUITextField
オブジェクトを取得します。 あなたの要件に合わせてTextFieldを使用することができます。
関連する問題
- 1. どのようにUITableViewCellからテキストフィールドの値を取得するには?
- 2. カスタムUITableViewCellがテキストフィールドを表示しない
- 3. は、UITableViewcellのテキストフィールドの代理人を設定します。
- 4. UITableViewCellのUITextFieldの元の値
- 5. キーボードをUITableViewCellのテキストフィールドに直接表示する方法
- 6. カスタムUITableViewCellのテキストフィールドから文字列を取得します
- 7. UITableViewCellフレームのNaN値が
- 8. フォーマットのテキストフィールドの値 - チタン
- 9. executeUpdateのテキストフィールド値を使用
- 10. テキストフィールドの値をハイライトする
- 11. IOS:テキストフィールドとダブル値
- 12. 配列内のUITableviewCellのテキストフィールドから文字列を追加したい
- 13. 別のフォームのテキストフィールドの値を渡す
- 14. ビュー間のテキストフィールドの値を渡すiphone
- 15. Javaスクリプトのテキストフィールドの設定値
- 16. テキストフィールドの値を取得し、分度器の別のテキストフィールドにコピー貼り付け
- 17. テキストフィールドでのカスタムセルの使用。スクロールでテキストフィールドの値が消えています
- 18. 値をテキストフィールドにリストする
- 19. ウィケット変更ラベル/テキストフィールド値
- 20. ヌル値を返すテキストフィールド
- 21. テーブルビューでテキストフィールドの値がスクロールしない
- 22. UIAutomationでテキストフィールドの値を取得する
- 23. テキストフィールドの値を取得する
- 24. テキストフィールド値の長さを確認する
- 25. テキストフィールドの値を変更する方法
- 26. テキストフィールド内のテキストフィールド値をどのように比較しますか?
- 27. テキストフィールドに入力されたデータベース値とテキストフィールド値を比較する方法
- 28. UITableViewCellの
- 29. ラベルとテキストフィールドを持つ再利用可能なUITableViewCellはありますか?
- 30. カスタムUITableViewCellの
このメソッドでは、ローカルのtextFieldを作成し、そのテキストを取得しようとしています。しかしそれは空であるべきです。そのクラスのグローバル値でtextFieldを保持する必要があります。 – alicanbatur