我目前正在将应用更新到iOS8,并且正在替换我自己的单元格高度计算.我有一堆自定义单元格的tableview.选择后的每个单元格都会将新视图显示/推送到navigationController.当使用这些单元格填充tableview,并且用户选择靠近表格底部的表格视图时,tableview会在显示新视图之前跳转到右上角.这对用户来说非常分散注意力.我正在尝试使用iOS 8中引入的自定义单元格(在viewDidLoad中):
self.tableView.estimatedRowHeight = 60.0;
self.tableView.rowHeight = UITableViewAutomaticDimension;
Run Code Online (Sandbox Code Playgroud)
这是选择单元格时的代码
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UIViewController *selectedViewController = [[UIStoryboard storyboardWithName:@"Trip" bundle:nil] instantiateViewControllerWithIdentifier:@"TripDetail"];
DetailViewController *destViewController = (id)selectedViewController;
[destViewController setData:self.dataStore];
[self.navigationController pushViewController:selectedViewController animated:YES];
}
Run Code Online (Sandbox Code Playgroud)
有谁知道为什么会这样?我怎么能让它停下来?
我只是想知道是否可以在没有动画的情况下显示详细视图控制器(从右侧滑入窗口)。我期望有某种动画布尔参数,但似乎没有。
这就是我所拥有的:
[self.splitViewController showDetailViewController:detailViewController sender:self];
Run Code Online (Sandbox Code Playgroud)
我在这里错过了什么吗?或者没有办法做到这一点吗?
cocoa-touch ipad uisplitviewcontroller ios presentviewcontroller
我试图理解为什么awakeFromNib 在我的代码中被调用两次。我目前有一个 tableview,它有一个特殊的可压缩单元格,在表格的末尾出现一次。当 tableview 最后滚动到特殊单元格时,将调用第一个awakeFromNib(我相信这很好,因为 tableview 正在重用单元格)。但是,每当我点击单元格以扩展单元格时,都会再次调用awakeFromNib。
谁能向我解释为什么awakeFromNib 被调用两次?我怎么只能让它只被调用一次?
谢谢
编辑**人们要求的代码
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.section >= (NSInteger)[self.trip.destinations count]) {
GuestCell *cell = (GuestCell*)[tableView dequeueReusableCellWithIdentifier:GuestCellIdentifier forIndexPath:indexPath];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
[cell setupCellForGuests:self.trip.guests];
cell.guestExpanded = NO;
NSLog(@"RETURNING CELL");
return cell;
}
// For all other sections
return [self prepareCardCellForIndexPath:indexPath forHeightCalc:NO];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.section >= (NSInteger)[self.trip.destinations count]) {
[self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
}
}
Run Code Online (Sandbox Code Playgroud)