相关疑难解决方法(0)

UIButton没有响应UITableViewCell中的click事件

在ios中有这种黑暗的巫术阻止我的按钮被点击.如果我没有向uitableviewcell添加按钮,并且我单击按钮,则会触发事件.但是如果按钮在uitableviewcell中,它就不会被触发,看起来表格我准备了示例代码,如果你们可以帮助我,请在xcode中创建一个简单的单视图应用程序,然后粘贴下面的代码

//GRDViewController.h

#import <UIKit/UIKit.h>

@interface GRDViewController : UIViewController <UITableViewDataSource, UITableViewDelegate>

@property (nonatomic, strong) UIView* container;
@property (nonatomic, strong) UIButton* button;
@property (nonatomic, strong) UITableView* tableView;
@property (nonatomic, strong) NSArray* arr;

@end
Run Code Online (Sandbox Code Playgroud)

//GRDViewController.m

#import "GRDViewController.h"

@implementation GRDViewController
@synthesize button, container, arr, tableView;

- (void)_btnTapped {
NSLog(@"TAPPED");
}

- (void)viewDidLoad 
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
    self.button = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];
    [self.button addTarget:self action:@selector(_btnTapped)    forControlEvents:UIControlEventTouchUpInside];
   [self.button setTitle:@"CLICK ME" forState:UIControlStateNormal];
  self.arr …
Run Code Online (Sandbox Code Playgroud)

touch uibutton uitableview ios

5
推荐指数
2
解决办法
9215
查看次数

标签 统计

ios ×1

touch ×1

uibutton ×1

uitableview ×1