导航栏会自动更改栏

时间:2015-08-12 13:01:46

标签: ios objective-c uinavigationcontroller uinavigationbar

我有一个包含UITAbleView的UIViewController。

enter image description here

我使用block从视图控制器推送新视图:

_noviyVC.presentPlease = ^(UIViewController *controller)
{
    [weakself.navigationController pushViewController:controller animated:YES];
};

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];

    ProfileVCC *profile = [[ProfileVCC alloc] init];
    profile.userId = _users[indexPath.row][@"id"];

    if (self.presentPlease)
    {
        self.presentPlease(profile);
    }
}

但最后我得到了这个:

enter image description here

导航栏将颜色更改为黑色。我做错了什么?

3 个答案:

答案 0 :(得分:2)

我无法理解为什么颜色会自动更改,但您可以使用下面的代码来设置颜色,还要检查您是否没有为UITableView的背景设置任何颜色。

if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) {
        // iOS 6.1 or earlier
        [self.navigationController.navigationBar setTintColor:[UIColor yellowColor]];
    } else {
        // iOS 7.0 or later     
        [self.navigationController.navigationBar setBarTintColor:[UIColor yellowColor]];
        self.navigationController.navigationBar.translucent = NO;
    };

答案 1 :(得分:2)

self.navigationController.navigationBar.barTintColor=ColorNav;
self.navigationController.navigationBar.translucent=FALSE;

答案 2 :(得分:0)

试试这个,

class MainThread implements Runnable

{
private Thread thread = null;
//private variables
..
..
 //default Constructor

 public MainThread(){}

public MainThread(int val){
 this.val=val;
}

    public void start() {
            thread = new Thread(this,"rootthread");
            thread.start();
        }

@Override
    public void run() {

    NormalWorkerClass1 instance1=NormalWorkerClass1.getInstance();  // Normal class
    NormalWorkerClass2 instance2=NormalWorkerClass2.getInstance(); // for other working
    try
        {
            while(true)
            {
                boolean retval=proccessSomething();
                if(retval)
                    {
                      instance1.doMainProcess(arg..);
                    }
                else
                {
                     instance2.doMainProcess(arg..);
                }
            }
        }
    }