0

I use a custom uitableviewcell in my uitableview. This cell has a uilable that centered in the entire cell with 20 point width constraint from right and left. Also the texts of uilable are center aligned.

I use this uitableview in a uitabbarcontroller.

The problem is that when I load the view in landscape mode or rotate the screen from portrait to landscape only the left side of the cell is selectable. It will be unselectable till I switch the tab. Even if I navigation to parent view controller and back to this page it is not selectable. The only thing that make all the cell selectable is changing the tab and backing!

enter image description here

For example in above screenshot if I tap yellow part the cell selects but if I tap red part or on the lable text nothing happens.

The other note is that if I switch the tab of the tabbar and back to this view, now every thing works fine.

Also please notice that I am using Arabic text.

Now does some one know that what is the problem?

EDIT

I notice that even all parts of the yellow part, is not selectable too. Only some left parts of the yellow section is click-able.

EDIT2

(I ADD IT IN THE CONTENT TOO)

I noticed that if I rotate the screen from portrait to landscape the problem is exist too( only the left side of the cell is selectable). It will be unselectable till I switch the tab. Even if I navigation to parent view controller and back to this page it is not selectable. The only thing that make all the cell selectable is changing the tab and backing!

Husein Behboudi Rad
  • 5,434
  • 11
  • 57
  • 115
  • Just check your springs and sturts for the custom tableviewcell are appropriate just select all of them – channi Jun 12 '14 at 07:27
  • Thanks for reply @channi but I do not get your meaning of "springs and struts". May you please specify more? – Husein Behboudi Rad Jun 12 '14 at 07:31
  • Just goto your xib file of CustomCell in utilities on right side pane select "Show the Size Inspector", there are the options to select autoresizing masks(which are also called springs and sturts) – channi Jun 12 '14 at 07:40
  • You are using auto-layout constraints, right? If yes, thats why you are not seeing "springs and struts" in Size Inspector. Is there only one element UILabel in the cell. Or there are others? In any case the landscape is creating the problem. You can set the colors of all elements to distinct colors also cell background color. To debug, whats going on in cell and other elements. For me, your question is un-clear. Try this debug technique and see if helps you. Cheers – Waleed Mahmood Jun 12 '14 at 07:42
  • I am using autolayout – Husein Behboudi Rad Jun 12 '14 at 07:44
  • @WaleedMahmood I am using autolayout. I had set the background color of the uilable and it shows that autolayout is working right. Also I only have one lable in the cell – Husein Behboudi Rad Jun 12 '14 at 07:45
  • Cell is getting over lapped with something, you need to check. Try this methods if it is working properly: - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath; – Waleed Mahmood Jun 12 '14 at 07:51
  • I am using this method and returning the height of the cell. This is the code: return 44; – Husein Behboudi Rad Jun 12 '14 at 07:53

2 Answers2

0

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { // do something before rotation }

(or)

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { // do something after rotation }

///added/////////

- (void)viewWillLayoutSubviews

{ if (UIInterfaceOrientationIsLandscape(self.interfaceOrientation)) { CGRect rect = self.yourtableView.frame; rect.size.width = 254; rect.size.height = 130; self.yourtableView.frame = rect; } else {

`}`

}

reload the table view in these methods

bvsss
  • 72
  • 6
0

by any chance, is your view inside a uiNavigationController?

simply_me
  • 384
  • 1
  • 11