Keeping a food diary helps but the only way to be sure is to do an elimination diet, which means to start from scratch and reintroduce foods gradually.
Having said that, UC can make you have diarrhea irrespective of what food you eat if you are flaring.
I did an elimination diet, SCD, and worked my way up to eating basically Whole 30, and that helped me understand what my body likes, tolerates, and doesn't tolerate.
But in the end what really works for me is suppositories, steroids and Humira, even though I still keep a food diary.