0

I have a navigation view and my second view will contains a table with custom UITableViewCell in it .

I have 2 issues

  1. when i am trying to open the application in Horizontal orientation (navigate to 2nd view ) and then Rotate the device in Portrait mode then i am getting a scroll in the Table View portion.

  2. when i open the 2nd view (in navigation) in portrait orientation and then rotate the device to horizontal and tries to swipe to get the delete button ,its not working particularly in Horizontal orientation.

  3. Delete buttons are covering my labels

I have used , custom UITableViewCell, AutoLayout and Storyboards

I have also uploaded my project for reference Link

Thanks in advance. !!

vinay chorpa
  • 187
  • 3
  • 16

1 Answers1

1

All the issues described by you are caused by bad layout. I have downloaded your project and corrected them. What I did: 1. Disabled autolayout. I did that for simplicity. This probably can be done with autolayout as well, but in this case it is much simpler without it. 2. Fixed autosizing for table view and the top label. 3. Fixed autosizing for the labels on table view cell. This fixes the delete button issue.

You can download the fixed project here.

EDIT: If you want to use autolayout you have to write some custom code as described in this answer.

NSDictionary *dict = NSDictionaryOfVariableBindings(myLabel2);
[cell.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:[myLabel2]|" options:0 metrics:nil views:dict]];

I have checked the code with your project and it worked. You can download the autolayout version here.

EDIT 2: To fix the rotation issue you can just reload the table view after interface orientation change:

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
    [super didRotateFromInterfaceOrientation:fromInterfaceOrientation];
    UITableView *tv = (UITableView *)[self.view viewWithTag:200];
    [tv reloadData];
}

Check it out here.

Community
  • 1
  • 1
Adam
  • 26,549
  • 8
  • 62
  • 79
  • First of all i appreciate your time for resolving my issue, But the thing is i am able to get the work done without autolayout but with autolayout its not working , It will certainly be great if somehow you can suggest a solution. – vinay chorpa Aug 20 '13 at 06:16
  • @vinaychorpa It can be done with autolayout as well. Check out my edited answer. – Adam Aug 20 '13 at 18:28
  • well dude your answer was super awesome and it worked like a charm .. flawless thanks a ton for this help . I know am getting greedy but one issue still left if i open the tableview in portrait mode and then rotate it to horizontal then delete isn't working and vice vera . Do you have any idea how to resolve this issue ? – vinay chorpa Aug 22 '13 at 07:33
  • @vinaychorpa Just reload the data as I did in my another edit. – Adam Aug 22 '13 at 12:17
  • man.. I just don't have word to explain how happy i am ... dude feels like give a big Hug for this solution thanks a ton man !!! God Bless . – vinay chorpa Aug 22 '13 at 13:28