matghazaryan / AMSlideMenu2

Sliding Menu for iOS (Left and Right menus). Multiple storyboards and XIBs support.
MIT License
1.2k stars 194 forks source link

Cell width not resizing to menu width, can't see accessory on the right #154

Closed batnom closed 9 years ago

batnom commented 9 years ago

I'm using an AMSlideMenu with Storyboards to show my left menu, but I couldn't see the accessory views.

Upon a bit of investigation it seems the cells aren't resizing to the width of the menu, so bits anchored the right side of the cell are hidden.

It's a bit hard to explain, so I've put some images in a cell (right aligned) to illustrate what I mean.

Storyboard and Simulator

The Pin image on the right is anchored to the right hand side, as is the share icon which must be way off outside of the visible menu. If the cells were resizing to the width of the menu, both would be visible.

I've tried using - (CGFloat)leftMenuWidth; which changes the size of the menu when it opens, but still doesn't change the width of the cells.

I'm sure I'm missing one little thing, can anyone point me in the right direction on where to set this?

arturdev commented 9 years ago

Please, can you try that with an empty UITableViewController and see if it works without AMSlideMenu? Just put a new UITableViewController in storyboard, set the checkbox "is Initial View Controller", put an imageview into a cell and set right anchor. I'm asking, because xcode has a bug with right anchoring in a tableviewcell.

Try that and let me know. Thanks

batnom commented 9 years ago

I've tried that and the non-AMSlideMenu test seems to be working:

Fresh UITableView

New UITableView, 3 static cells with some left and right anchored labels/imageviews, set as initial view controller.

andrew020 commented 9 years ago

@batnom , Have you resolved your problem? in the demo, I found some code fit your problem. write these code in your customize AMSlideMenuLeftTableViewController,

@interface LeftTableViewController () @property (strong, nonatomic) UITableView *myTableView;

@end

@implementation LeftTableViewController

pragma mark - Method

batnom commented 9 years ago

@andrew020 That's fantastic, have got it working thank you!

Here's my final fixUI function:

- (void)fixUI {

    self.myTableView = self.tableView;

    // Colour

    self.view = [[UIView alloc] initWithFrame:self.view.bounds];
    self.view.backgroundColor = self.myTableView.backgroundColor;

    // Width (for accessories)

    CGRect fixFrame = self.myTableView.frame;
    fixFrame.size.width = [UIScreen mainScreen].bounds.size.width - 70;
    self.myTableView.frame = fixFrame;

    // Status Bar

    UIView *statusBarView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, MAX(self.view.frame.size.width,self.view.frame.size.height), 20)];
    statusBarView.backgroundColor = [UIColor blackColor];
    [self.view addSubview:statusBarView];

    // Done

    [self.view addSubview:self.myTableView];

}