首页 > 其他 > 详细

从Cell的视图推出一个新的界面

时间:2016-08-16 23:35:26      阅读:273      评论:0      收藏:0      [点我收藏+]

先写一个方法, 强制增加一个navigation的属性. 这样self就可以调出来navigation了

- (UINavigationController*)naviController {
    
    for (UIView* next = [self superview]; next; next = next.superview) {
        
        UIResponder* nextResponder = [next nextResponder];
        
        if ([nextResponder isKindOfClass:[UINavigationController class]]) {
            
            return (UINavigationController*)nextResponder;
        }
    }
    
    return nil;
}

 然后, 在cell的点击方法中调用这个属性, 并推出一个新的界面:

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
    
    myViewController *vc = [[myViewController alloc]init];
    
    [[self naviController] presentViewController:vc animated:YES completion:nil];
    
}

 

从Cell的视图推出一个新的界面

原文:http://www.cnblogs.com/mafeng/p/5778041.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!