1

Here the story, before, i use xcode 4 and using library ECSSlidingView Menu, it work nicely but after i clone it to new project using xcode 5, many thing messed up, even with no code change!

the view shifted up, and the imageview isn't displayed

Before

After

both using this chunk of code (tell me if you need more)

For CellView @implementation SideMenuTableViewCell

@synthesize indexpath;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setAccessoryCheckmarkColor:[UIColor whiteColor]];
        [self setDisclosureIndicatorColor:[UIColor whiteColor]];
        [self setAccessoryCheckmarkColor:[UIColor whiteColor]];
        // Disable this as this will overlaped with draw to stroke line
        //UIView * backgroundView = [[UIView alloc] initWithFrame:self.bounds];
        //[backgroundView setAutoresizingMask:UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth];
        //[backgroundView setBackgroundColor:[CustomConfiguration CFG_THEME_COLOR_BLUE]];
        //[self setBackgroundView:backgroundView];
        //
        [self setBackgroundColor:[CustomConfiguration CFG_THEME_COLOR_BLUE]];
        [self setBackgroundColor:[UIColor clearColor]];
        [self.textLabel setTextColor:[CustomConfiguration CFG_THEME_COLOR_YELLOW]];
        [self.textLabel setFont:[CustomConfiguration CFG_THEME_FONT_LARGEBUTTON]];
    }
    return self;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    // Configure the view for the selected state
}
- (void)setAccessoryType:(UITableViewCellAccessoryType)accessoryType{
    [super setAccessoryType:accessoryType];
    if(accessoryType == UITableViewCellAccessoryCheckmark){
        MMCustomCheckmark * customCheckmark = [[MMCustomCheckmark alloc] initWithFrame:CGRectMake(0, 0, 15, 15)];
        [customCheckmark setColor:self.accessoryCheckmarkColor];
        [self setAccessoryView:customCheckmark];
    }
    else if(accessoryType == UITableViewCellAccessoryDisclosureIndicator){
        MMDisclosureIndicator * di = [[MMDisclosureIndicator alloc] initWithFrame:CGRectMake(0, 0, 10, 14)];
        [di setColor:self.disclosureIndicatorColor];
        [self setAccessoryView:di];
    }
    else {
        [self setAccessoryView:nil];
    }
}
// Configure cell.imageView size and position
- (void)layoutSubviews {
    [super layoutSubviews];
    self.imageView.frame = CGRectMake(50, 50, 25, 25);
}
-(void)drawRect:(CGRect)rect{
    if (self.indexpath.row > 0) {
        return;
    }
    //// General Declarations
    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
    CGContextRef context = UIGraphicsGetCurrentContext();
    //// Frames
    CGRect frame = CGRectMake(0, -1, CGRectGetWidth(self.bounds), CGRectGetHeight(self.bounds)+1);

    UIColor *customWhite = [UIColor colorWithRed:251.0/255.0 green:251.0/255.0 blue:249.0/255.0 alpha:1];    

    //// Fill Drawing

    CGRect fillRect = CGRectMake(CGRectGetMinX(frame), CGRectGetMinY(frame), CGRectGetWidth(frame), CGRectGetHeight(frame) - 1);
    UIBezierPath* fillPath = [UIBezierPath bezierPathWithRect: fillRect];
    CGContextSaveGState(context);
    [fillPath addClip];

    CGContextRestoreGState(context);

    //// TopStroke Drawing
    // Do not draw top stroke unless section index is greater than 0
    if (self.indexpath.section > 0) {
        UIBezierPath* topStrokePath = [UIBezierPath bezierPathWithRect: CGRectMake(CGRectGetMinX(frame), CGRectGetMinY(frame)+1, CGRectGetWidth(frame), 1)];
        [customWhite setFill];
        [topStrokePath fill];
    }
    //// Highlight Drawing

    //// BottomStroke Drawing
    if (self.indexpath.row == 0) {
        UIBezierPath* bottomStrokePath = [UIBezierPath bezierPathWithRect: CGRectMake(CGRectGetMinX(frame), CGRectGetMinY(frame) + CGRectGetHeight(frame) - 1, CGRectGetWidth(frame), 1)];
        [customWhite setFill];
        [bottomStrokePath fill];
    }
    //// Cleanup
    //CGGradientRelease(gradient2);
    CGColorSpaceRelease(colorSpace);
}

@end

For TableView, method cellForRowAtIndexPath

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellIdentifier = @"MenuItemCell";
    UITableViewCell *cell = (UITableViewCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    // Always redraw tanle cell
    //if (cell == nil) {
    cell = [[SideMenuTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    [cell setSelectionStyle:UITableViewCellSelectionStyleBlue];
    [(SideMenuTableViewCell *)cell setIndexpath:indexPath];
    //}
    cell.imageView.bounds = CGRectMake(0, 0, 10, 10);
    switch (indexPath.section) {
        case MMDrawerSectionAccountSection:
            switch (indexPath.row) {
                case 0: {
                    cell.imageView.image = Nil;
                    cell.textLabel.text = [tableView.dataSource tableView:tableView titleForHeaderInSection:indexPath.section];
                    break; }
                case 1: {                             
                    [cell.textLabel setText:[NSString stringWithFormat:@"%@ %@", [self.profileData valueForKey:@"firstName"], [self.profileData valueForKey:@"lastName"]]];
                    cell.imageView.image = [UIImage imageNamed:@"user.png"];
                    UILazyImageView *lazyImage = [[UILazyImageView alloc] init];
                    [lazyImage loadImageWithURL:[self.profileData valueForKey:@"photoURL"]];
                    // Resize photo profile                    
                    CGRect resizeRect;
                    resizeRect.size = cell.imageView.image.size;
                    resizeRect.origin = CGPointMake(0.0, 0.0);
                    UIGraphicsBeginImageContext(resizeRect.size);
                    [lazyImage.image drawInRect:resizeRect];
                    UIImage *resizedImage = UIGraphicsGetImageFromCurrentImageContext();
                    UIGraphicsEndImageContext();
                    cell.imageView.image = resizedImage;
                    break; }
                case 2: {
                    [cell.textLabel setText:LOC_EN_SIDEMENU_SAVEDARTICLE];
                    cell.imageView.image = [UIImage imageNamed:@"saved.png"];
                    break; }
                case 3: {
                    [cell.textLabel setText:LOC_EN_SIDEMENU_SAVEDHOSPITAL];
                    cell.imageView.image = [UIImage imageNamed:@"savedhospital.png"];
                    break; }
                case 4: {
                    [cell.textLabel setText:LOC_EN_SIDEMENU_LOGOUT];
                    cell.imageView.image = [UIImage imageNamed:@"logout.png"];
                    break; }
            }
            //[cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];
            break;
        case MMDrawerSectionMenuSection:{
            switch (indexPath.row) {
                case 0: {
                    cell.imageView.image = Nil;
                    cell.textLabel.text = [tableView.dataSource tableView:tableView titleForHeaderInSection:indexPath.section];
                    break; }
                case 1: {
                    [cell.textLabel setText:LOC_EN_SIDEMENU_NEWSFEED];
                    [cell.imageView setImage:[UIImage imageNamed:@"newsfeed.png"]];
                    break; }
                case 2: {
                    [cell.textLabel setText:LOC_EN_SIDEMENU_ARTICLE];
                    cell.imageView.image = [UIImage imageNamed:@"article.png"];
                    break; }
                case 3: {
                    [cell.textLabel setText:LOC_EN_SIDEMENU_HOSPITAL];
                    cell.imageView.image = [UIImage imageNamed:@"pinmenu"];
                    break; }
                case 4: {
                    [cell.textLabel setText:LOC_EN_SIDEMENU_PURCHASE];
                    cell.imageView.image = [UIImage imageNamed:@"purchase"];
                    break; }
            }
            //[cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];
            break;
        }
        default:
            break;
    }
    return cell;
}
DeckyFx
  • 1,308
  • 3
  • 11
  • 32
  • possible duplicate of [Status bar and navigation bar appear over my view's bounds in iOS 7](http://stackoverflow.com/questions/17074365/status-bar-and-navigation-bar-appear-over-my-views-bounds-in-ios-7) – Wain Jan 07 '14 at 08:00
  • 1
    hi @Wain..I'm not following.. can you describe how it gonna be dupe? – Ahmad Azwar Anas Jan 07 '14 at 08:04
  • Seconded, tell me more – DeckyFx Jan 07 '14 at 08:06
  • Check this : few of your problem solves: **http://stackoverflow.com/questions/20650821/how-to-make-the-cell-wider-in-ios6-ipad/20650973#20650973** **http://stackoverflow.com/questions/19159621/converting-ios-6-app-to-ios-7/19159882#19159882** – Kumar KL Jan 07 '14 at 08:06
  • Thank you @KumarKl but ECSTablView didn't declared in storyboard, its all in script, so i can't really make use your suggestion, anyway thanks. – DeckyFx Jan 07 '14 at 08:11
  • Does `cell.imageView` return nil? – KudoCC Jan 07 '14 at 08:22
  • Not tried, but i guess no since line "cell.imageView.bounds = CGRectMake(0, 0, 10, 10);" nor any other imageview method didn't throw error – DeckyFx Jan 07 '14 at 08:32
  • @DeckyFx No error will occur if you send method to a nil object in Objective-C. – KudoCC Jan 07 '14 at 08:34
  • with NSLOG "%@" > – DeckyFx Jan 07 '14 at 08:49

1 Answers1

0

You need to write this piece of code:-- http://pastie.org/8703954 As well you need to set cell background colour as ClearColour..

Mohit
  • 516
  • 7
  • 24