gpt4 book ai didi

ios - 获取索引路径 如果用户在 UITableview 中编辑 UITextfield

转载 作者:行者123 更新时间:2023-11-28 19:46:54 24 4
gpt4 key购买 nike

我正在使用如下图所示的 UITableview。如果我输入单价和数量,我需要计算。但是现在我不知道如何获取 UITableView 中两个文本框的索引路径。在 UITableView 中,如果单击按钮转到 didSelectRowAtIndexPath 方法。当我在 qty 和 unitprice 文本框中输入时,没有调用相同的方法。

enter image description here

InvoiceMainViewController.h

    #import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>

@class InvoiceGridViewController;

@protocol InvoiceTableCellProtocoll <NSObject>
-(void) didPressButton:(InvoiceGridViewController *)theCell;
@end

@interface InvoiceGridViewController : UITableViewCell {
id<InvoiceTableCellProtocoll> delegationListener; }

@property (nonatomic,assign) id<InvoiceTableCellProtocoll> delegationListener;
@property (nonatomic,retain) IBOutlet UITextField *invoiceItem;
@property (nonatomic,retain) IBOutlet UITextField *invoiceUnitPrice;
@property (nonatomic,retain) IBOutlet UITextField *invoiceQty;
@property (nonatomic,retain) IBOutlet UITextField *invoiceTaxRate;

@property (nonatomic,retain) IBOutlet UILabel *invoiceItemId;
@property (nonatomic,retain) IBOutlet UILabel *invoiceCurrencyId;
@property (nonatomic,retain) IBOutlet UILabel *invoiceTaxRateId;

@property (nonatomic,retain) IBOutlet UILabel *totalItemTax; @property
@property (nonatomic,retain) IBOutlet UILabel *converstionMessage;

-(IBAction)deleteSel:(id)sender;
-(void)delFileSel;
@end

InvoiceMainViewController.m

#import <UIKit/UIKit.h>
#import "SBPickerSelector.h"
#import <Foundation/Foundation.h>
#import "AFHTTPRequestOperationManager.h"
#import "AFURLResponseSerialization.h"
#import "AFURLRequestSerialization.h"
#import "InvoiceGridViewController.h"


@interface InvoiceMainViewController : UIViewController<UITableViewDataSource, UITableViewDelegate,NSXMLParserDelegate,UITextFieldDelegate,InvoiceTableCellProtocoll>{

最佳答案

你可以通过多种方式做到这一点

类型 -1

// get the current visible rows

NSArray *paths = [yourtableName indexPathsForVisibleRows];
NSIndexPath *indexpath = (NSIndexPath*)[paths objectAtIndex:0];

2 型

你可以得到你触摸了哪个单元格

 CGPoint touchPoint = [sender convertPoint:CGPointZero toView: yourtableName];
NSIndexPath *clickedButtonIndexPath = [mainTable indexPathForRowAtPoint: yourtableName];

Type-3

 add `TapGestuure ` for get the current cell.

Type-4

- (void) textFieldDidEndEditing:(UITextField *)textField {
CGRect location = [self convertRect:textField.frame toView:self.tableView];
NSIndexPath *indexPath = [[self.tableView indexPathsForRowsInRect:location] objectAtIndex:0];

// Save the contents of the text field into your array:
[yourArray replaceObjectAtIndex:indexPath.row withObject:textField.text];
}

例子

如果您需要更多信息,请在此处查看 link

关于ios - 获取索引路径 如果用户在 UITableview 中编辑 UITextfield,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31608829/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com