重新创建和理解 iOS 设置菜单
Recreating and understanding iOS settings menu
我想重新创建 iOS 设置菜单。为此,我需要了解这是如何创建的。请在下面找到示例:
我的理解是,这是一个 masterdetailview 控制器样式的项目,左侧是 table 视图,右侧是带有自定义单元格的详细视图。
我发现 this answer 可以重新创建分组,但还不知道如何创建自定义操作。
- 如何创建像下面这样的自定义单元格来调整亮度(它有一个 滑块)?
- 如何像 Apple 一样添加标签和按钮?每个单元格都有单独的 xib 文件吗?
要添加自定义 UITableViewCell,您的 ViewController 中应该有一个 UITableView。
然后您可以通过向项目添加新文件来添加自定义 UITableViewCell。
现在你可以看到项目中添加了3个文件。转到 XIB 文件并根据需要对其进行修改。最后去
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath method & add these lines in it.
static NSString *MyIdentifier = @"MyIdentifier"; //Set Identifier for cell
CustomCell *cell = (CustomCell *)[tableView dequeueReusableCellWithIdentifier: MyIdentifier]; //init CustomCell
if (cell == nil) { //Check cell is nill or not
NSArray *nib;
nib = [[NSBundle mainBundle] loadNibNamed:@"CustomCell"
owner:self options:nil]; //if cell is nil add CustomCell Xib
for (id oneObject in nib) if ([oneObject isKindOfClass:[CustomCell class]])
cell = (CustomCell *)oneObject;
}
//Set Cell Values Here
return cell;
我想重新创建 iOS 设置菜单。为此,我需要了解这是如何创建的。请在下面找到示例:
我的理解是,这是一个 masterdetailview 控制器样式的项目,左侧是 table 视图,右侧是带有自定义单元格的详细视图。
我发现 this answer 可以重新创建分组,但还不知道如何创建自定义操作。
- 如何创建像下面这样的自定义单元格来调整亮度(它有一个 滑块)?
- 如何像 Apple 一样添加标签和按钮?每个单元格都有单独的 xib 文件吗?
要添加自定义 UITableViewCell,您的 ViewController 中应该有一个 UITableView。
然后您可以通过向项目添加新文件来添加自定义 UITableViewCell。
现在你可以看到项目中添加了3个文件。转到 XIB 文件并根据需要对其进行修改。最后去
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath method & add these lines in it.
static NSString *MyIdentifier = @"MyIdentifier"; //Set Identifier for cell
CustomCell *cell = (CustomCell *)[tableView dequeueReusableCellWithIdentifier: MyIdentifier]; //init CustomCell
if (cell == nil) { //Check cell is nill or not
NSArray *nib;
nib = [[NSBundle mainBundle] loadNibNamed:@"CustomCell"
owner:self options:nil]; //if cell is nil add CustomCell Xib
for (id oneObject in nib) if ([oneObject isKindOfClass:[CustomCell class]])
cell = (CustomCell *)oneObject;
}
//Set Cell Values Here
return cell;