我有导航栏。当我将按钮添加到导航栏时,它不会显示。
代码:
UINavigationController *nav=[[UINavigationController alloc]init];
[self.view addSubview:nav.view];
UIImage *info_iphone=[UIImage imageNamed:@"infobtn_iphone.png"];
UIButton *infobtn=[[UIButton alloc]initWithFrame:CGRectMake(0, 0, 48, 30)];
[infobtn setBackgroundImage:info_iphone forState:UIControlStateNormal];
[infobtn addTarget:self action:@selector(show_info) forControlEvents:UIControlEventTouchUpInside];
self.navigationItem.rightBarButtonItem=[[UIBarButtonItem alloc]initWithCustomView:infobtn];