I already told you -- you cannot call fitInView() before the view is first shown because it has no size yet. You can find as many "codes on web" but they will all fail because of the same reason. You need to do as I told you -- call fitInView() when the view is already visible.