如何创建一个页面来显示像iPhone上的关于某些字段的信息有Disclosure指标?

时间:2010-10-13 15:12:06

标签: iphone uitableview

我想知道如何构建一个与iPhone上的“关于”屏幕完全相同的屏幕。

我想以这种格式显示信息..它如此干净..

任何想法?

1 个答案:

答案 0 :(得分:2)

嗯,它只是一个分组类型UITableView,很容易创建。在Interface Builder中创建它并选择“Grouped”作为Type&将它与您的班级联系起来或以编程方式创建它:

示例:

UITableView * myTable = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320, 465) style:UITableViewStyleGrouped];

        [myTable setDelegate:self];

        [myTable setDataSource:self];

        [controllerView addSubview:myTable];

        [myTable reloadData];

        [myTable release];

然后,您需要在.accessoryView中定义- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath属性。我们举个例子创建一个开关作为单元的accessoryView:

  cell.textLabel.text = @"Donation Reminder"; 
  UISwitch*donationSwitch = [[[UISwitch alloc] initWithFrame:CGRectMake(0, 0, 50, 27)] autorelease];
  cell.accessoryView = donationSwitch;
瞧,开关将是它的子视图。如果您只想要文本,就像在您的问题中一样,只需在创建Switch时创建UILabel。