iphone – 表脚中的UIButton没有响应
发布时间:2020-12-14 18:05:22 所属栏目:百科 来源:网络整理
导读:对于自定义表格页脚,我使用以下代码 - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section { if(editmode) { if(footerView == nil) { //allocate the view if it doesn't exist yet footerView = [[UIView alloc] in
对于自定义表格页脚,我使用以下代码
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section { if(editmode) { if(footerView == nil) { //allocate the view if it doesn't exist yet footerView = [[UIView alloc] init]; //we would like to show a gloosy red button,so get the image first UIImage *image = [[UIImage imageNamed:@"button_green.png"] stretchableImageWithLeftCapWidth:8 topCapHeight:8]; //create the button UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [button setBackgroundImage:image forState:UIControlStateNormal]; //the button should be as big as a table view cell [button setFrame:CGRectMake(10,3,300,44)]; //set title,font size and font color [button setTitle:@"Photo" forState:UIControlStateNormal]; [button.titleLabel setFont:[UIFont boldSystemFontOfSize:20]]; [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; //set action of the button [button addTarget:self action:@selector(selectExistingPicture) forControlEvents:UIControlEventTouchUpInside]; //add the button to the view [footerView addSubview:button]; UIButton *button2 = [UIButton buttonWithType:UIButtonTypeRoundedRect]; image = [[UIImage imageNamed:@"button_grey_dark.png"] stretchableImageWithLeftCapWidth:8 topCapHeight:8]; [button2 setBackgroundImage:image forState:UIControlStateNormal]; //the button should be as big as a table view cell [button2 setFrame:CGRectMake(10,50,font size and font color [button2 setTitle:@"Note" forState:UIControlStateNormal]; [button2.titleLabel setFont:[UIFont boldSystemFontOfSize:20]]; [button2 setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; //set action of the button [button2 addTarget:self action:@selector(mkFolder) forControlEvents:UIControlEventTouchUpInside]; //add the button to the view [footerView addSubview:button2]; // [button setupAsRedButton]; } //return the view for the footer return footerView; } return nil; } 使用它,第一个按钮响应完美,但第二个按钮不记录任何事件.即使该函数不存在,也不会生成空函数错误.关于UITouchUpInside未被识别的任何想法? 解决方法
卫生署!
在这段代码的正下方,我有 // specify the height of your footer section - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { //differ between your sections or if you //have only on section return a static value return 50; } 这使得UIView忽略了50像素以下的任何东西.将它改为100,我很好. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |