我有一个表视图控制器,它有大约6个静态单元格,所有这些我都希望指向独立的外部URL。应该够直截了当的,但我似乎想不出该怎么做。目前我正在使用故事板,还没有为表视图创建任何自定义类。
谁能给我指明正确的方向?
发布于 2014-03-31 22:34:54
井。创建自定义UIViewController类。然后转到故事板,选择新的UIViewController类作为“自定义类”。
右键单击“从静态表视图拖动到文件所有者”并选择“委托”,以便接收单元格上的抽头。
然后实现
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath方法。例如,像这样:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if(indexPath.row==0)
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.google.com"]];
}else if(indexPath.row==1)
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.bing.com"]];
}
}这是最快的方法..。
https://stackoverflow.com/questions/22773426
复制相似问题