Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UIButton分组按钮_Ios_Iphone_Uibutton - Fatal编程技术网

Ios UIButton分组按钮

Ios UIButton分组按钮,ios,iphone,uibutton,Ios,Iphone,Uibutton,我正在尝试创建一个按钮设置,完全如下所示: 我该怎么做?谁能给我看看密码吗?有没有办法像这样“分组”UI按钮?这是一个包含两行(单元格)的单组UI表格视图。表格样式为UITableViewStyleGroup。我建议使用代理的–tableView:didSelectRowAtIndexPath:方法响应单元格的选择,而不是在单元格内使用UIButtons,这会产生更好的视觉效果。您需要使用UITableViewController,并将节设置为uitableViewStyleGroup 每个组

我正在尝试创建一个按钮设置,完全如下所示:


我该怎么做?谁能给我看看密码吗?有没有办法像这样“分组”UI按钮?

这是一个包含两行(单元格)的单组UI表格视图。表格样式为UITableViewStyleGroup。我建议使用代理的
–tableView:didSelectRowAtIndexPath:
方法响应单元格的选择,而不是在单元格内使用UIButtons,这会产生更好的视觉效果。

您需要使用
UITableViewController
,并将节设置为
uitableViewStyleGroup

每个组都是一个节,因此您需要使用
-(NSInteger)numberOfSectionsInTableView:(UITableView*)tableView
返回您拥有的节数

对于每个节,您都希望使用
-(NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)节指定有多少行

您需要使用
-(UITableViewCell*)tableView:(UITableView*)tableView cellforrowatinexpath:(nsindepath*)indepath
(顺便说一句,它告诉您在
indepath
变量中修改的特定行的节)

最后,您需要使用XCode为您提供的模式处理
-(void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath
中的行单击:

[self.navigationController pushViewController:detailViewController animated:YES];
[detailViewController release];

希望这有帮助

你不能这样分组。您可以通过多种方式实现这种外观,最优雅的是使用分组样式uitableview。
但是,如果您只希望按钮看起来像这样,而不是完全像这样,那么您也可以为按钮指定图像。更丑陋的方法,无论多么简单…

为了进一步回答您的问题,您可以在不使用
ui按钮的情况下执行此操作。只需使用
UITableViewController
,让它对选择的单元格做出响应。