简体   繁体   English

UITableViewCell在iPhone和iPad上的工作方式有所不同

[英]UITableViewCell works differently on iPhone and iPad

Folks it appears that setSelected:animated: works differently on iPhone and iPad, even in simulator. 人们似乎发现setSelected:animated:在iPhone和iPad上甚至在模拟器中的工作方式都不同。 Consider the code below: 考虑下面的代码:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell* cell = [tableView cellForRowAtIndexPath:indexPath];
    if (cell.accessoryType == UITableViewCellAccessoryNone)  {
            //[cell setSelected:NO animated:YES]; works only on iPhone, but not on iPad
              [tableView deselectRowAtIndexPath:indexPath animated:YES]; //works everywhere
    return;
    }

    [self.navigationController pushViewController:someViewController animated:YES];

} }

it appears this line works only on iPhones 看来这行仅适用于iPhone

[cell setSelected:NO animated:YES];

I was wondering if anybody could provide some information on setSelected:animated: method's limitations? 我想知道是否有人可以提供有关setSelected:animated:方法的限制的信息?

I think that's by design on iPads since UITableViews aren't really intended to be used outside of UISplitViewControllers. 我认为这是在iPad上设计的,因为UITableViews并非真正打算在UISplitViewControllers之外使用。

If using a UITableView in viewControllers[0] consider how the UITableViewCell will remain to be selected while the user is interacting with the UIViewController in viewControllers[1]. 如果在viewControllers [0]中使用UITableView,请考虑在用户与viewControllers [1]中的UIViewController交互时如何保持UITableViewCell处于选中状态。

edit 编辑

I can't support this at all... I looked it up in the HIG and it says nothing like what I mentioned. 我根本无法支持这一点……我在HIG中进行了查找,但并没有提到我所说的内容。

http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/TableView_iPhone/AboutTableViewsiPhone/AboutTableViewsiPhone.html#//apple_ref/doc/uid/TP40007451 http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/TableView_iPhone/AboutTableViewsiPhone/AboutTableViewsiPhone.html#//apple_ref/doc/uid/TP40007451

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM