What should I do to adapt my app to iOS 5.0 keeping compatibility with iOS 4

后端 未结 4 728
盖世英雄少女心
盖世英雄少女心 2021-02-10 05:05

I\'ve started playing with iOS 5 today and I\'ve seen that XCode 4.2 only let me select iOS 5 as Base SDK but not iOS 4.

Until now I\'ve overwriting drawRect: method in

4条回答
  •  时光取名叫无心
    2021-02-10 05:53

    Another way to customized your header is like this.

    UIImage *image = [UIImage imageNamed:@"header.png"];
    
    if([navigationBar respondsToSelector:@selector(setBackgroundImage:forBarMetrics:)] ) {
        //iOS 5 new UINavigationBar custom background
        [navigationBar setBackgroundImage:image forBarMetrics: UIBarMetricsDefault];
    } 
    else{
        UIImageView *imgView = [[[UIImageView alloc] initWithImage:image] autorelease];
        [imgView setUserInteractionEnabled:NO];
        [imgView setTag:TOOLBAR_TAG];
        [navigationBar insertSubview:imgView atIndex:0];
    }
    

    Using the respondsToSelector you can know if the function is here.

提交回复
热议问题