UITableViewCell向上移动自定义segue出现/解除

时间:2014-10-17 01:50:06

标签: objective-c uitableview ios8 uinavigationbar segue

我有一个MasterViewController,使用自定义模态segue,呈现详细视图。来自GitHub上的mluisbrown的自定义模态动画是LCZoomTransition。目前,我遇到的问题导致我的tableview的单元格在选择时向上移动。 Maybe AutoLayout?

我不知道是什么原因引起的。我的代码用于显示详细信息视图:

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

    EditViewController *edit = [[EditViewController alloc]init];

    NSManagedObjectContext *mo = [_fetchedResultsController objectAtIndexPath:indexPath];
    [edit setManagedObjectContext:mo];



    id appDelegate= [[UIApplication sharedApplication] delegate];
    self.managedObjectContext = [appDelegate managedObjectContext];


    OweInfo *info = [_fetchedResultsController objectAtIndexPath:indexPath];

    self.editView = edit;


    self.editView.delegate = self;
    self.editView.info = info;

    edit.info = info;
    edit.delegate = self;
    edit.managedObjectContext = [appDelegate managedObjectContext];



    self.editView.managedObjectContext = [appDelegate managedObjectContext];
[self performSegueWithIdentifier:@"pushToEdit" sender:self];



}

和我的segue代码:

if([segue.identifier  isEqual: @"pushToEdit"]){


        NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
        self.zoomTransition.sourceView = [self.tableView cellForRowAtIndexPath:indexPath];
               // pass the custom transition to the destination controller
        // so it can use it when setting up its gesture recognizers
        [[segue destinationViewController] setGestureTarget:self.zoomTransition];
    EditViewController *edit = segue.destinationViewController;

        NSManagedObjectContext *mo = [_fetchedResultsController objectAtIndexPath:indexPath];
        [edit setManagedObjectContext:mo];


        id appDelegate= [[UIApplication sharedApplication] delegate];
        self.managedObjectContext = [appDelegate managedObjectContext];


        OweInfo *info = [_fetchedResultsController objectAtIndexPath:indexPath];
            self.editView = edit;


        self.editView.delegate = self;
        self.editView.info = info;
    self.editView.managedObjectContext = self.managedObjectContext;
    edit.managedObjectContext = self.managedObjectContext;

        edit.info = info;
        edit.delegate = self;





    }

任何人都知道这可能导致什么?这是在iOS 8和Xcode 6上。

应该是什么样子: Workin

1 个答案:

答案 0 :(得分:0)

在我看来,你正在复制多个控制器。

didSelectRowAtIndexPath中应该包含对segue的调用。

然后只创建一个viewController实例

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [self performSegueWithIdentifier:@"pushToEdit" sender:self];
}

就是这样,你在segue委托中完成剩下的工作,并避免重复实例。