【发布时间】:2015-09-08 05:33:15
【问题描述】:
我制作了一个自定义视图类。我在我的视图控制器类中初始化它。我已经启用了用户交互,但它也不起作用。我在类似的问题中搜索过它,但大多数都说启用用户交互。
这是我写的代码。
@interface ProfileCreatorViewController (){
SectionTitleView *ProfileTitle;
CGRect mainFrame;
}
@end
@implementation ProfileCreatorViewController
- (void)viewDidLoad {
[super viewDidLoad];
mainFrame = CGRectMake(self.view.frame.origin.x, self.view.frame.origin.y + NAVBAR_HEIGHT, self.view.frame.size.width, self.view.frame.size.height);
CGRect profileFrame = CGRectMake(mainFrame.origin.x + 5, mainFrame.origin.y, mainFrame.size.width - 20, 50);
ProfileTitle = [[SectionTitleView alloc]initWithFrame:profileFrame withTitle:@"Profile" withUnderLineColor:[UIColor blackColor] withDownButton:[UIImage imageNamed:@"rightArrow"]];
[self.view addSubview:ProfileTitle];
UITapGestureRecognizer *recog = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(downButtonClicked)];
[ProfileTitle addGestureRecognizer:recog];
ProfileTitle.userInteractionEnabled = YES;
}
-(void) downButtonClicked{
NSLog(@"clicked");
}
【问题讨论】:
标签: ios objective-c uiview uitapgesturerecognizer