ios - 自定义应用程序中的 UITableview 部分

标签 ios iphone uitableview ios5

在我的应用程序中,我有 3 个类别(部分),每个类别中有 3 个项目(行)。
我已经通过使用分组样式 UITableview 来实现它.

但它的分组方式不适合我的应用程序流程。

如何定制UITableview部分?

我实际上想要 3 个 block 类型的部分,而且我应该能够选择整个 block 而不是单个子类别(即行)。当用户选择整个 block 时,将出现新的 Controller 。他们有什么方法吗:-didSelectSectionAtIndexpath ?所以可以对整个部分执行整个操作?

最佳答案

您可以按如下方式创建自定义页眉 View ,并以同样的方式设置页脚

对于标题

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
   UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 18)];

 /* Create custom view to display section header... */

UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 5, tableView.frame.size.width, 18)];
[label setFont:[UIFont boldSystemFontOfSize:12]];
 NSString *string =[list objectAtIndex:section];

 /* Section header is in 0th index... */

[label setText:string];
[view addSubview:label];
[view setBackgroundColor:[UIColor colorWithRed:166/255.0 green:177/255.0 blue:186/255.0 alpha:1.0]]; //your background color...
return view;

}

对于页脚
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section;   // custom view for footer. will be adjusted to default or specified footer height

您需要以一种整体看起来相同的方式创建两个 View (根据您的 UI 要求)

关于ios - 自定义应用程序中的 UITableview 部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21525899/

相关文章:

iphone - 为什么 applicationWillTerminate : delegate does not fire on minimize?

ios - 自定义 UITableViewCell 中缺少附件

ios - 检索对象 ID

ios - 使用 CodeMagic 部署时如何增加 Flutter IOS 应用程序的内部版本号

ios - UITabBarController canBecomeFirstResponder 方法未被调用

objective-c - 更改 UIDocument 交互图标

ios - 带有 insertRowAtIndexPath 的动态 UITableViewCell

ios - UICollectionView prepareForSegue 通过手势点击 UIImageView

iphone - 如何从iPhone浏览音频/声音?

iphone - 关于iPhone中的正则表达式