I am using following code to switch view when click on other tab to show a different content(not sure whether it's propert way to do that, but now I can change the conent when clicking on the tab bottom button)
-(void) favBtnClick:(id*)sender{
NSLog(@"fav btn clicked");
FavouriteViewController *tgt = [[FavouriteViewController alloc]init];
[self presentViewController:tgt animated:YES completion:nil];
}
Now that the view was drawn from the very top of the screen, and I think it will be neater to add a title in the view so I tried following in the target view of videDidLoad
function, but nothing happens, the title was not shown:
UINavigationBar* navbar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, 500, 50)];
UINavigationItem* item = [[UINavigationItem alloc] initWithTitle:@"title text"];
[navbar pushNavigationItem:item animated:YES];
navbar.backgroundColor=[UIColor redColor];
[self.view addSubview:navbar];
How to make this work?
尝试设置FavouriteViewController实例的title
属性。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.