2013-09-30 456 views
0

我有這兩個問題,在iOS7中,我想不出。iOS7狀態欄問題,我想不出

第一個問題是TableView行位於狀態欄下方,我如何禁用它或使表格視圖的節頭始終位於狀態欄下方?

status bar status bar

我已經是導航控制器的狀態欄,似乎是黑色與黑色的背景上,我不知道如何解決它的第二個問題,在視圖控制器背景是白色的,但狀態欄提醒黑色,我不知道爲什麼。

black status bar

UPDATE:

仍然沒有回答。

+0

與第一個問題相同的問題在這裏。我解決了你的第二個問題,讓我的導航欄更高。看到我的代碼在下面! –

回答

0

我認爲你需要做下面的代碼。

您將必須檢查條件爲ios7。

您將需要這兩個委託方法的tableview。

請查看下面的代碼。

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section 
{ 
    NSString *currSysVer = [[UIDevice currentDevice] systemVersion]; 

    int versionValue=[currSysVer intValue]; 

    if(versionValue>=7) 
    { 
     return 60; 
    } 
    return 0; 
} 

- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section 
{ 
    UIView *headerView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 60)]; 

    [headerView setBackgroundColor:[UIColor clearColor]]; 

    return headerView; 
} 

希望這可以幫助你。

+0

我已經在使用這2個委託方法,用我的方法取代了你的方法,仍然不起作用,看起來相同並且行爲相同。我只是想出來。 –

+0

這在xcode5和ios7中適用於我。檢查您是否正確設置了代表。 – Manthan

0

回答你的第二個問題!

把你的didFinishLaunchingWithOptions:

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) { 

     [self customizeios7]; 

    } else { 

     [self customizeios6]; 

    } 

並使這些2個空隙:

-(void)customizeios6 { 

    UIImage *navBackgroundImage = [UIImage imageNamed:@"navigationbar-ios6"]; 

    [[UINavigationBar appearance] setBackgroundImage:navBackgroundImage forBarMetrics:UIBarMetricsDefault]; 

} 

-(void)customizeios7 { 

    // SET STATUSBAR TEXT WHITE 

    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; 

    // SET NAVIGATION IMAGE 

    UIImage *navBackgroundImage = [UIImage imageNamed:@"navigationbar-ios7"]; 

    [[UINavigationBar appearance] setBackgroundImage:navBackgroundImage forBarMetrics:UIBarMetricsDefault]; 

} 

您UINavigationBar的圖像尺寸:

對於iOS 6:

640像素/ 88px

對於iOS 7:

640像素/ 128 x 96像素

0

使用這些代碼行

if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]) { 
    // iOS 7 
    [self prefersStatusBarHidden]; 
    [self performSelector:@selector(setNeedsStatusBarAppearanceUpdate)]; 
} else { 
    // iOS 6 
    [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide]; 
} 

- (BOOL)prefersStatusBarHidden 
{ 
    return YES; 
} 
+0

這不是工作的人。 –

+0

但它爲我工作...不知道它的nt爲你工作.. :-( – Amitabha

+0

添加在viewDidLoad方法 – Amitabha