How to add a right button to a UINavigationController?

后端 未结 21 1179
不思量自难忘°
不思量自难忘° 2020-11-28 18:25

I am trying to add a refresh button to the top bar of a navigation controller with no success.

Here is the header:

@interface PropertyViewController          


        
21条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-28 18:45

        self.navigationItem.rightBarButtonItem =[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(refreshData)];
    
    
    
    }
    
    -(void)refreshData{
        progressHud= [MBProgressHUD showHUDAddedTo:self.navigationController.view animated:YES];
        [progressHud setLabelText:@"拼命加载中..."];
        [self loadNetwork];
    }
    

提交回复
热议问题