作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
是否可以像按钮一样使用 tableView 单元格?在我的应用程序中,我想要一个有 4 行的 TableView ,每行都有标签。我想要的是当我触摸一行时,table tableview 单元格应该像按钮一样 react (执行操作并且突出显示背景)?那可能吗?我怎样才能做到这一点?谢谢。
最佳答案
非常简单,委托(delegate)方法将被调用 didSelectRowAtIndexPath 在那里你可以得到在哪个部分点击了哪一行,你可以执行进一步的操作。
例如
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// deselect
[tableView deselectRowAtIndexPath:indexPath animated:YES];
if(indexPath.row == 0){
LoginFormViewController *vController = nil;
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
vController = [[LoginFormViewController alloc] initWithNibName:@"LoginFormViewController_ipad" bundle:nil];
}else {
vController = [[LoginFormViewController alloc] initWithNibName:@"LoginFormViewController" bundle:nil];
}
[self.navigationController pushViewController:vController animated:YES];
[vController release];
}
}
关于iphone 开发 : using tableview cells as a button,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12330577/
我是一名优秀的程序员,十分优秀!