gpt4 book ai didi

ios - 使用子类 UITableViewCell 的 scrollToRowAtIndexPath

转载 作者:行者123 更新时间:2023-11-28 22:20:47 27 4
gpt4 key购买 nike

我有一个包含两个 TextField 的子类 UITableViewCell,我想知道如何使用子类中的 scrollToRowAtIndexPath

我已经设置了 UITextField 委托(delegate),我只是不知道如何将消息发送回原始 ViewController 以操作 UITableViewRow 以在键盘上方向上滚动。

subclasscell.h

@interface CustomFinishingCell : UITableViewCell

subclasscell.m

cell.heightTextField.delegate = self;
cell.widthTextField.delegate = self;


callingclass.m
//cellForRow
cell.heightTextField.text = heightString;

//textFieldShouldBeginEditing, action scroller here...

所以我不太确定如何从子类单元格类访问 textfieldshouldbeginediting,以便在按下 UItextField 时我可以在键盘上方滚动 tableviewcell。

最佳答案

在单元格中存储自定义数据以标识单元格,viewController 可以使用它来查找单元格的索引路径。

为您的单元格创建一个协议(protocol)并让您的 viewController 实现它。

喜欢

@protocol YourDelegate <NSObject>
- (void)textFieldGetResponderIn:(CustomFinishingCell *)cell ;
@end

当调用 textfieldshouldbeginediting 时,调用 [delegate textFieldGetResponderIn:self] ;

你像这样实现你的单元格:

@protocol YourDelegate ;

@interface CustomFinishingCell : UITableViewCell

@property (nonatomic, assign) id<YourDelegate> delegate ;
@property (nonatomic, strong) id customeData ;

@end


@protocol YourDelegate <NSObject>
- (void)textFieldGetResponderIn:(CustomFinishingCell *)cell ;
@end

关于ios - 使用子类 UITableViewCell 的 scrollToRowAtIndexPath,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20467613/

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