我有一个UIButton
在我从xib
加载的tableviewCell
内。 通过单击该按钮,它应该转到下一个视图... 我已经为此写了回电..
这是我在 xib 中的代码 TableViewCell.h
typedef void(^CallBack)(UIButton *sender);
@property (copy, nonatomic) CallBack callBack;
TableViewCell.m
- (IBAction)buttonTapped:(id)sender {
if (_callBack) {
_callBack(sender);
}
在视野中控制器
cell.callBack = ^(UIButton *sender) {
[self performSegueWithIdentifier:@"segueIdentifier" sender:nil];
};
表演Segue线正在击中,但它需要一些时间才能击中...为什么
试试这个:
@interface WACustomCell : UITableViewCell
@property(readwrite,copy)void (^cellCallBackMethod)(NSInteger rowIndexPath);
-(IBAction)buttonTappedFromCell:(id)sender;
@end
@implementation WACustomCell
@synthesize cellCallBackMethod;
-(IBAction)buttonTappedFromCell:(id)sender{
self.cellCallBackMethod(0);
//any value can be given as we will retrieve this value from CellForRowAtIndex method
}
在视图中控制器
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
cel = ....
cell.cellCallBackMethod = ^(NSInteger cellIndex)
{
[self cellButtonTappedFromCellWithIndex:cellIndex];
};
return cell;
}
-(void)cellButtonTappedFromCellWithIndex:(NSInteger )cellIndex
{
[self performSegueWithIdentifier:@"segueIdentifier" sender:nil];
}
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier]isEqualToString:@"segueIdentifier"])
{
ViewController1 *vc = [segue destinationViewController];
}
}
从自定义 UIButton 和 UIView 中将用户交互启用设置为 NO 解决了我的问题...感谢您的回复...