0

这就是我在 viewDidLoad 的第一堂课中设置图像的方式,即 tableView

  if ([self.navigationController.navigationBar respondsToSelector:@selector(setBackgroundImage:forBarMetrics:)]) {
        [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"header.png"] forBarMetrics:UIBarMetricsDefault];
    }

now this how i go to detail view

 DetailViewController *dvController = [[DetailViewController alloc]   initWithNibName:@"DetailViewController" bundle:[NSBundle mainBundle]];
      [self.navigationController pushViewController:dvController animated:YES];

在详细视图的栏中,我为导航栏设置的图像会自动出现在那里,一切都很完美

现在我的问题是 pushViewController 工作正常 图像正在显示,但我在 presentModelViewController 中获得了默认图像,这就是我使用它的方式

- (void) modelappear
{

    if (self.testModalViewController == nil) 
    {
        TestModalViewController *temp = [[TestModalViewController alloc] initWithNibName:@"TestModalViewController" bundle:[NSBundle mainBundle]];
        self.testModalViewController = temp;
        [temp release];
    }

    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:self.testModalViewController];
    [self presentModalViewController:nav animated:YES];
}

注意我只是在内部层次结构视图中设置按钮

你能告诉我我在做什么错吗?请给出解释和答案非常感谢

4

3 回答 3

0

试试这样

     DetailViewController *dvController = [[DetailViewController alloc]   initWithNibName:@"DetailViewController" bundle:[NSBundle mainBundle]];
     dvController.topViewController.navigationController.navigationBar.tintColor = [UIColor colorWithPatternImage:[UIIMage imageNamed:@"name.png"]];
[self presentModalViewController:nav animated:YES];
于 2013-04-19T06:20:46.513 回答
0
UIImage *image = [UIImage imageNamed:@"header.png"];
    UIImageView *imageView = [[UIImageView alloc] initWithImage:image];

    [self.navigationController.navigationBar addSubview:imageView];
于 2013-04-19T06:46:20.233 回答
0
   UIImage *image = [UIImage imageNamed:@"header.png"];
    UIImageView *imageViewe = [[UIImageView alloc] initWithImage:image];


    UILabel *tmpTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(100, 3, 150, 40)];
    [tmpTitleLabel setFont:[UIFont boldSystemFontOfSize:18]];


    tmpTitleLabel.text = @"Add Manually";

    tmpTitleLabel.backgroundColor = [UIColor clearColor];

    tmpTitleLabel.textColor = [UIColor whiteColor];

    CGRect applicationFrame = CGRectMake(0, 0, 300, 40);
    UIView * newView = [[[UIView alloc] initWithFrame:applicationFrame] autorelease];
    [newView addSubview:imageViewe];
    [newView addSubview:tmpTitleLabel];


    [self.navigationController.navigationBar addSubview:newView];
于 2013-04-22T04:52:49.547 回答