- objective-c - iOS 5 : Can you override UIAppearance customisations in specific classes?
- iphone - 如何将 CGFontRef 转换为 UIFont?
- ios - 以编程方式关闭标记的信息窗口 google maps iOS
- ios - Xcode 5 - 尝试验证存档时出现 "No application records were found"
您在下面看到的是 Tweetbot iPhone application 的屏幕截图.我想问的是,如果您知道我可以实现 Tapbots 人员在他们的 tableView 中实现的目标的方法:您点击前 tableView 的一个单元格,它会显示一组操作,再次点击它就会消失。
这是一个非常酷的实现,我很想知道您对我如何做到这一点的看法,这既是为了练习,也是因为我希望在未来的项目中使用它的变体。
有什么想法吗?
最佳答案
当用户选择单元格时,保存所选单元格的索引路径并在其下方添加一行。如果用户选择相同的销售隐藏它下面的行。如果用户选择另一个单元格,则隐藏当前选定的单元格并在新选定的单元格下方显示一个新单元格。
@interface RCTableViewController ()
@property (nonatomic, strong) NSMutableArray *tableViewData;
@property (nonatomic, strong) NSIndexPath *selectedIndexPath;
@end
@implementation RCTableViewController
@synthesize tableViewData = _tableViewData;
@synthesize selectedIndexPath = _selectedIndexPath;
- (void)viewDidLoad
{
[super viewDidLoad];
self.tableViewData = [NSMutableArray arrayWithObjects:
@"Cell 0",
@"Cell 1",
@"Cell 2",
@"Cell 3",
@"Cell 4",
@"Cell 5",
@"Cell 6",
@"Cell 7",
@"Cell 8",
nil];
self.selectedIndexPath = nil;
[self.tableView reloadData];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return self.tableViewData.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell;
if (indexPath == self.selectedIndexPath) {
static NSString *DropDownCellIdentifier = @"DropDownCell";
cell = [tableView dequeueReusableCellWithIdentifier:DropDownCellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:DropDownCellIdentifier];
}
cell.textLabel.text = @"Drop Down Cell";
} else {
static NSString *DataCellIdentifier = @"DataCell";
cell = [tableView dequeueReusableCellWithIdentifier:DataCellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:DataCellIdentifier];
}
cell.textLabel.text = [self.tableViewData objectAtIndex:indexPath.row];
}
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSIndexPath *dropDownCellIndexPath = [NSIndexPath indexPathForRow:indexPath.row + 1
inSection:indexPath.section];
if (!self.selectedIndexPath) {
// Show Drop Down Cell
[self.tableViewData insertObject:@"Drop Down Cell" atIndex:dropDownCellIndexPath.row];
[tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:dropDownCellIndexPath]
withRowAnimation:UITableViewRowAnimationTop];
self.selectedIndexPath = indexPath;
} else {
NSIndexPath *currentdropDownCellIndexPath = [NSIndexPath indexPathForRow:self.selectedIndexPath.row + 1
inSection:self.selectedIndexPath.section];
if (indexPath.row == self.selectedIndexPath.row) {
// Hide Drop Down Cell
[self.tableViewData removeObjectAtIndex:currentdropDownCellIndexPath.row];
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:currentdropDownCellIndexPath]
withRowAnimation:UITableViewRowAnimationTop];
self.selectedIndexPath = nil;
} else if (indexPath.row == currentdropDownCellIndexPath.row) {
// Dropdown Cell Selected - No Action
return;
} else {
// Switch Dropdown Cell Location
[tableView beginUpdates];
// Hide Dropdown Cell
[self.tableViewData removeObjectAtIndex:currentdropDownCellIndexPath.row];
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:currentdropDownCellIndexPath]
withRowAnimation:UITableViewRowAnimationAutomatic];
// Show Dropdown Cell
NSInteger dropDownCellRow = indexPath.row + ((indexPath.row >= currentdropDownCellIndexPath.row) ? 0 : 1);
dropDownCellIndexPath = [NSIndexPath indexPathForRow:dropDownCellRow
inSection:indexPath.section];
[self.tableViewData insertObject:@"Drop Down Cell" atIndex:dropDownCellIndexPath.row];
[tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:dropDownCellIndexPath]
withRowAnimation:UITableViewRowAnimationAutomatic];
self.selectedIndexPath = [NSIndexPath indexPathForRow:dropDownCellIndexPath.row - 1
inSection:dropDownCellIndexPath.section];
[tableView endUpdates];
}
}
}
@end
关于ios - 定制的 tableView à la Tweetbot,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9227359/
我目前被指派去调查并以某种方式找到一种“定制”(对身份验证、常量、消息等进行修改)OpenSSH 的方法,并且作为一个“基于网络”的人,我真的不知道从哪儿开始。因此非常感谢评论。 问题: 我从 her
我拥有的 excel 文件超过 1,000,000 行和 26 列。 下面是用于查找特定数据的代码,并根据该数据创建一个新文件,目前创建一个新文件大约需要 15 分钟 请如果有专家可以帮助我更快地处理
我正在处理Zend_Form现在,我很难弄清楚如何: 使用表单按钮的自定义图像, 在特定位置插入文本和链接(就我而言,我想在提交按钮之前添加“忘记密码?”链接)。 我已通读手册,但没有看到任何相关内容
是否可以将图像添加到 UISwitch 背景,例如当状态为 ON 时(作为一个背景)和当状态为 OFF 时(另一个背景图像)? 最佳答案 要更改背景颜色(不是图像),您只需执行以下操作即可。这会更改领
到目前为止,我刚刚开始使用 Octave 并在我的终端上运行它。 每次打开提示符时,我的命令行都以: octave-3.4.0:1> 因此我使用以下内容来使其更短且更易于阅读: PS1('>> ')
在阅读Struts2文档时,我遇到了下面引用的段落 customizing controller - Struts 1 lets to customize the request processor
我正在尝试自定义 jQuery Tag-It 小部件 (http://aehlke.github.com/tag-it/) 以实现以下两种行为: 1)允许在标签中使用逗号(我可以通过自定义trigge
我是整个 Emacs 的新手,让我着迷的一件事是开箱即用的 Emacs 在编程时不会让您陷入困境。我主要使用 Python 和 C++ 进行编程,然后按回车键将光标发送回新行的第 1 列,而不是让你停
我有这些行 y DB,我想按以下顺序排序,并包含字符和数字。 Score 列是一个 varchar。获胜者和失败者也在分数栏中。 得分 WINNER 100+ 100 90 80+ 80 50 LOS
我正在使用 Bootstrap,您如何自定义轮播? 有什么建议吗? https://v4-alpha.getbootstrap.com/components/carousel/ 最佳答案 .activ
我有一个投票设置,使用脚本将其拉入我的 WP 页面。通过http://quipol.com/ EG 我已经通过 firebug 找到了样式并在其中相应地自定义了它们,但我想知道是否有一种方法可以实现
美好的一天。 如果 JLabel 和 JTextField 字体大小可以根据需要更改,是否也可以更改 JTable 的列名称和元素的字体样式(大小、外观、颜色)? 添加更多内容,我正在使用 Windo
进一步回答我的问题Java JFilechooser 。建议扩展 BasicFileChooserUI,重写 create/getModel 并提供 BasicDirectoryModel 的实现。
我想制作(好吧..正在制作..)一个标签页。我用 border-top:none 属性制作了一个“选项卡框”,所以它看起来像是选项卡的一部分,在里面我有一个表格。 我想知道,有没有办法删除表格标题的所
我有大量的项目正在进行中,还有几个解决方案(它们是项目“池”的子集)。有时拥有一个仅用于特定测试的 .sln 是件好事。 问题: NUGet 分别绑定(bind)到每个解决方案。 NUGet 喜欢在
我计划编写一些 git 钩子(Hook)作为一个项目,将用户的操作记录在数据库中。然后可以使用该数据库查询他的所有事件。我尝试记录的操作是 promise pull 推送 merge 分支机构 我想把
大家好,我是张飞洪,感谢您的阅读,我会不定期和你分享学习心得,希望我的文章能成为你成长路上的垫脚石,让我们一起精进。 在本文中,我们将学习中间件,以及如何使用它进一步定制应用程序。我
我正在尝试使用 yasg 自定义我的 api 文档。 首先,我想确定我自己的部分的命名,以及本部分应包含哪些端点。似乎部分的命名是基于不属于最长公共(public)前缀的第一个前缀,例如: 如果我们有
我需要(即客户要求)提供自定义键盘,供用户在文本字段和区域中输入文本。我已经有一些可以执行键盘操作并将测试附加到文本字段的东西,但是我想让它更通用并让它像标准的 iphone 键盘一样工作,即当用户选
我有一个项目,它在特定位置(不是/src/resources)包含资源(模板文件)。我希望在运行 package-bin 时将这些资源打包。 我看到了 package-options 和 packag
我是一名优秀的程序员,十分优秀!