ios - UIButton 分组按钮

标签 ios iphone uibutton

我正在尝试创建一个完全像这样设置的按钮:

alt text

我该怎么做?有人可以告诉我代码吗?有没有办法像这样“分组”UIButton?

最佳答案

您需要使用 UITableViewController 并将部分设置为 UITableViewStyleGrouped

每个组都是一个部分,因此您需要使用 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 返回您有多少个部分。

对于每个部分,您要指定有多少行 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

您需要使用 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 自定义每个单元格(顺便说一句,告诉您哪个部分是特定的indexPath 变量中修改的行)。

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

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

希望这对您有所帮助!

关于ios - UIButton 分组按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4588370/

相关文章:

iphone - UIScrollview 类似动画的分页

ios - 如何获得从 UIView 到 ViewController 的按钮点击?

iphone - 我应该保存哪些私钥才能重建我的 iOS 应用程序?

iphone - 如何开始为 iOS 开发配件?

iphone - 在 CGAffineTransform 之后转换父/子 UIView 之间的坐标

ios - 以编程方式更改 UIButton 的标题在 iOS Xcode-Beta 3 中不起作用

iphone - iPhone音频修改(过滤器/效果)

ios - UIProgressView 在 iOS 7 中显示问题

swift - 以编程方式图像为 UIButton 但没有属性

iphone - iOS 在单击按钮时加载全新的 View