iOS:一些界面效果的实现

     独立于控制器的视图/按钮

        例如一些购物车悬浮栏,在不同控制器中总是悬浮在屏幕下端,点击它可以查看已添加商品。
          方法一:使用多重窗口;扩展点可以看看 《Multiple Display Programming Guide for iOS》
    // 创建 UIWindow,设置相关属性
    // <span style="font-family: Arial, Helvetica, sans-serif;">makeKeyAndVisible</span>
    // window 上面添加 视图
    // 自定义视图
//备注,上述过程可以任意放在需要的位置,当创建UIwindow,并且makeKeyAndVisible时候,视图就显示出来了
        方法二:添加到UIWindow上;
[window addSubview:navigationController.view];
[window insertSubview:disclaimerController.view aboveSubview:navigationController.view];
[window makeKeyAndVisible];
         注意,目标视图 添加到window上,window的“rootViewController”的视图必须也是addSubviews到windwos,如果 它是赋给window的rootViewControllrer属性,则添加到window上的视图将会看不到
          问题:只有一个视图可以接受旋转事件, Beginning with iOS 6, only the topmost view controller (alongside the UIApplication object) participates in deciding whether to rotate in response to a change of the device's orientation 换句话说,In your situation its probably the fact that you are adding the view as another subview to the window. Only the first subview gets the rotation events
          解决办法:
0.把需要旋转的放前面:What you can do is add it as a subview of the first window subview。
1.Add listener and update view
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(statusBarFrameOrOrientationChanged:) name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(statusBarFrameOrOrientationChanged:) name:UIApplicationDidChangeStatusBarFrameNotification object:nil];
2.kvo,监听前面视图的center, bounds and transform,然后相应方法update view。
            方法三:如果是navigationController是rootViewController,自定义一个VC继承系统NaviVC,然后在viewdidload里面addsubview 到self.view上面



  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值