注册

ios 导航栏问题

在demo的基础上改界面需求,发现申请前与通知返回按钮不见了,我看了代码有设置,但不起作用,找不出原因

8443E82C-E7C0-4ECE-8B62-6712956B2B3C.png




DBB78D3F-33A1-499B-9A0C-E0333A6CA1AF.png

已邀请:

donghai

赞同来自: 不轻易言弃

您把相关代码发上来一下,一般这种情况,是UI出现的问题!
UIButton *backButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 44, 44)];

    [backButton setImage:[UIImage imageNamed:@"back.png"] forState:UIControlStateNormal];

    [backButton addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];

    UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];

    [self.navigationItem setLeftBarButtonItem:backItem];

这是设置导航栏上返回按钮的代码,您仔细检查一下,是否出现错误
是啊,是这样设置的
您的工程中[UIImage imageNamed:@"back.png"]    有back.png这张图片吗? 您点击左上角的时候,是不是也可以跳转页面呢? 
 
我注释掉导航栏的代码,点击左边区域也能返回的,
 // Uncomment the following line to preserve selection between presentations.

    self.title = NSLocalizedString(@"title.apply", @"Application and notification");

    self.tableView.tableFooterView = [[UIView alloc] init];

    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;

    

    UIButton *backButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 20, 20)];

    [backButton setImage:[UIImage imageNamed:@"back.png"] forState:UIControlStateNormal];

    [backButton addTarget:self.navigationController action:@selector(popViewControllerAnimated:) forControlEvents:UIControlEventTouchUpInside];

    UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];

    [self.navigationItem setLeftBarButtonItem:backItem];

   

    

    [self loadDataSourceFromLocalDB];

    
addTarget:self.navigationController   改成addTarget:self   试一试

要回复问题请先登录注册