Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 11 - Crash on adding subview inside VKSideMenu

I have been using the VKSideMenu library for implementing slide menu. I have a created a button click for animating the same. The code was working perfectly before iOS 11 but since when I updated my iPhone to iOS11 the app gets crashed whenever I clicked on the button. Adding an exception breakpoint helped me to find out where the cause is but I could not found the reason for that cause anywhere .

In the VKSideMenu.m file, I got the issue at

[self.view addSubview:self.tableView];

where the self.tableView indicates the tableview for displaying the menu. But the tableview was not nil.

like image 665
hamedazhar Avatar asked Jan 30 '23 04:01

hamedazhar


1 Answers

After hours of sitting, I finally got the solution. Replace this line

[self.view addSubview:self.tableView];

with

[[(UIVisualEffectView *)self.view contentView] addSubview:self.tableView];

If you want to add a subview ( for e.g., a subview named subViewName) to that view, you have to add this:

[[(UIVisualEffectView *)self.view contentView] addSubview:subViewName];

like image 155
hamedazhar Avatar answered Feb 04 '23 04:02

hamedazhar