zoukankan      html  css  js  c++  java
  • iOS 7 Development Tips, Tricks & Hacks


    iOS 7 Development Tips, Tricks & Hacks
    September 18, 2013
    Like with any new iOS version there are a bunch of new tricks and hacks to work out. Here are a few things that weren't immediately obvious to me, it's in no way a complete set, just things that I happened to come across.
    If you've got any more then send them to me on Twitter or by email and I'll add them here with full credit to you.
    Stealing The Blur
    Unfortunately Apple didn't give access to their blur effect directly for you to use on your views. Luckily some clever people worked out you could just steal the layer from a UIToolbar. iOS-blur
    If you want dark style blur set the toolbar barStyle to UIBarStyleBlack.
    Tinting The Navbar
    Setting the tint color but it's not tinting? Turns out there's another tint property called 'barTintColor';
       self.navigationController.navigationBar.barTintColor = [UIColor blueColor];
    Nil Those Delegates
    With iOS 7 you need to nil out your delegates and datasources before your controllers are dealloc'd or you will have a lot of nasty 'message sent to deallocated instance' exceptions.
        - (void)dealloc
        {
            self.tableView.delegate = nil;
            self.tableView.dataSource = nil;
        }
    Hide The Status Bar
    Don't you love how that transparent status bar floats over content? Yeah me either.
    The standard call doesn't do the trick any more:
       [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade]
    Set the value UIViewControllerBasedStatusBarAppearance to YES in your Info.plist and add this to your controller:
        - (BOOL)prefersStatusBarHidden
        {
            return YES;
        }
    Changing The Status Bar Style Per Controller
    Set the value UIViewControllerBasedStatusBarAppearance to YES in your Info.plist and override:
     - (UIStatusBarStyle)preferredStatusBarStyle
     {
         return UIStatusBarStyleLightContent;
     }
    Custom Back Button And Swipe Back
    The only nice way I found to actually completely override the back button is to set the leftBarButtonItem, but then the swipe back gesture breaks. Luckily it's an easy fix when you know how:
        self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]
                                                 initWithImage:img
                                                 style:UIBarButtonItemStylePlain
                                                 target:self
                                                 action:@selector(onBack:)];
        self.navigationController.interactivePopGestureRecognizer.delegate = (id<UIGestureRecognizerDelegate>)self;
    Full Screen Content Transition
    When full screen content is shown (say a video is expanded) and the user switches orientation and then closes you will often get an exception. Turns out preferredInterfaceOrientationForPresentation is now a required method.
        - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
        {
            return UIInterfaceOrientationPortrait;
        }
    Checking For iOS 7
    Nothing new here, but useful if you want to perform something only on iOS 7:
        if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
            ...
        } 
    My Scroll View Is Moving!
    iOS 7 offsets your scroll view 64px (20px for the status bar and 44px for the navigation bar) by default, you can disable this though:
      self.automaticallyAdjustsScrollViewInsets = NO;
    CocoaPods Is Breaking in Xcode 5
    Check out this link.

  • 相关阅读:
    https下 http的会被阻塞 This request has been blocked; the content must be served over HTTPS.
    一文揭秘定时任务调度框架quartz
    JAVA开发者的Golang快速指南
    postman传递对象到spring controller的方式
    Go语言程序结构分析初探
    avalon1.3的新特性预览
    html标签对应的英文原文
    迷你MVVM框架 avalonjs 实现上的几个难点
    firebug,chrome调试工具的使用
    迷你MVVM框架 avalonjs 1.2.4发布
  • 原文地址:https://www.cnblogs.com/newBlash/p/4351786.html
Copyright © 2011-2022 走看看