zoukankan      html  css  js  c++  java
  • 从Cell的视图推出一个新的界面

    先写一个方法, 强制增加一个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];
        
    }
    
  • 相关阅读:
    类的继承
    垃圾回收GC
    网络层
    数据链路层
    TCP/IP协议分层模型
    OSI参考模型
    浏览器访问一个域名的过程
    Thread&ThreadLocal
    设计模式---单例模式
    内存泄漏和内存溢出
  • 原文地址:https://www.cnblogs.com/mafeng/p/5778041.html
Copyright © 2011-2022 走看看