UIButton in custom UITableViewCell stops working after rotation

Problem:

I used a custom UITalbeViewCell, which contains two buttons, they work fine in portrait orientation. After turning, they all stop responding to a button press inside the function. Some people have problems that their buttons could not draw correctly after rotation. My game looked great, as the buttons appear in the right places after rotation, but they no longer respond to a button click.

For this particular view in my application, I used the UIPageController to implement multiple pages in the view, and for the view (now the name EmbeddedView) built into the page scroll controller, there is a UITableView that contains a custom UITableViewCell. The user cell for viewing the table has only a tip; the owner of the file is EmbeddedView.

in EmbeddedView:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { /*===== This is the most memory efficient way of creating table view cells =====*/ static NSString *CellIdentifier = @"CellIdentifier"; CustomTableViewCell *cell = (CustomTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { [[self customTableCellNib] instantiateWithOwner:self options:nil]; cell = [self customTableCell]; [self setCustomTableCell:nil]; } } 

What I tried:

I created another nib file for a cell of a custom table view and used it in -cellForRowAtIndexPath (), I checked the orientation and dynamically created the cell using another thread, no luck.

I added [tableview reloadData] to -didRotateFromInterfaceOrientation (), did nothing.

Can someone point me in the right direction, please? Any help is appreciated.

This is a table view of Autosizing in IB:

enter image description here

It looks right, but the buttons do not work

enter image description here

Update: I tried to specify various Autosizing masks in IB to represent the table, and the results are shown below:

<1>

enter image description hereenter image description here

enter image description here

<2>

enter image description hereenter image description here

enter image description here

<3>

enter image description here

enter image description here

<4>

enter image description here

<T411>

+6
source share
1 answer

Have you checked how the size of the supervisor changes?

Check to see if it says "clip to borders". If this is not a test. This will make the clip view its contents so that you can see if it has changed normally.

I would say that the supervisor is not correct, and due to this event, touches are also not delivered.

EDIT. So, that was the advice that allowed the OP to reach a solution:

What I usually do in case of unexpected resizing behavior is changing each view in the hierarchy to a different, well-recognized color. Right now, you have view A and view B with the same background color (or crisp), and you don’t see if view B. changes well. Good luck.

+4
source

All Articles