Button.onClick.AddListener() doesn't work

This may be a little bit of a beginner question but I’ve looked through various posts that I could find about Button.onClick.AddListener() and followed the solutions to other people’s problems, but when I check the button component in the editor after the code runs it says that there is nothing in OnClick(). Idk if this will help but the game object that the component is attached to is disabled while this is happening.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class UIManager : MonoBehaviour {
     // this variable is assigned in the editor to a GameObject with a button component
     public GameObject button;
     public bool buttonPressed;
     int i = 1;
     void Start () {
          button.GetComponent<Button>().onClick.AddListener(() => ButtonPress(i));
     void ButtonPress (int i) {
          buttonPressed = true;


Methods added to onClick via script will not be showed in the edtor, although they do work.