bennyguitar / CollapseClick

A collapsible list that functions like a UITableView, except you can collapse and open cells on a click. Feed it UIViews for what is shown when each cell is open. Works via delegation similar to UITableView.
MIT License
533 stars 83 forks source link

Storyboard? #5

Open svaz opened 11 years ago

svaz commented 11 years ago

ANy chance that there will be a storyboard example anytime soon?

bennyguitar commented 11 years ago

The way to do this in storyboard should be the same as using it regularly.

ryanmsusa commented 11 years ago

Drap and drop a generic view onto the storyboard. Then set a custom class for that generic view

farazhaider88 commented 10 years ago

is there any way to use it using storyboard?

petec029 commented 10 years ago

Cool control but not sure how to get it working in a storyboard. You can not just drop a view onto the storyboard unless it is in a view controller. Wondering if there is a way to get it to work using a container view. http://stackoverflow.com/questions/11386111/uiview-outside-of-a-view-controller-in-a-storyboard

daviddelmonte commented 10 years ago

I used this approach: You don't drop the view into the storyboard but add the UIView to the list of components for the specific ViewController. Please see the attached screenshots.

screen shot 2014-04-27 at 5 21 19 am screen shot 2014-04-27 at 5 20 50 am

daviddelmonte commented 10 years ago

And the ViewController.m:

// // ViewController.m // CollapseClick // // Created by Ben Gordon on 2/28/13. // Copyright (c) 2013 Ben Gordon. All rights reserved. //

import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

@synthesize itemArray; @synthesize item; @synthesize category; @synthesize date1; @synthesize date2; @synthesize serial;

pragma mark - Collapse Click Delegate

// Required Methods -(long)numberOfCellsForCollapseClick { return 5; }

-(NSString *)titleForCollapseClickAtIndex:(long)index { NSLog(@"%s", FUNCTION); switch (index) { case 0: return @"Item Information"; break; case 1: return @"User Information"; break; case 2: return @"Company Information"; break;

    case 3:
        return @"Images";
        break;
    case 4:
        return @"Notes";
        break;

    default:
        return @"";
        break;
}

}

-(UIView *)viewForCollapseClickContentViewAtIndex:(long)index { // NSLog(@"%s", FUNCTION); switch (index) {

    case 0:
        return itemView;
        break;
    case 1:
        return test2View;
        break;
    case 2:
        return test3View;
        break;

    case 3:
        return nil;
        break;
    case 4:
        return notesView;
        break;

    default:
        return test3View;
        break;
}

}

-(void) jumpToImages { NSLog(@"images....."); }

// Optional Methods

-(UIColor *)colorForCollapseClickTitleViewAtIndex:(long)index { return [UIColor colorWithRed:223/255.0f green:47/255.0f blue:51/255.0f alpha:1.0]; }

-(UIColor *)colorForTitleLabelAtIndex:(long)index { return [UIColor colorWithWhite:1.0 alpha:0.85]; }

-(UIColor *)colorForTitleArrowAtIndex:(long)index { return [UIColor colorWithWhite:0.0 alpha:0.25]; }

-(void)didClickCollapseClickCellAtIndex:(long)index isNowOpen:(BOOL)open { NSLog(@"%ld and it's open:%@", index, (open ? @"YES" : @"NO")); if (index == 3) [self jumpToImages]; }

-(void)textFieldDidBeginEditing:(UITextField *)textField{ //NSLog(@"%s", FUNCTION);

[textField setReturnKeyType:UIReturnKeyDone];

}

pragma mark - TextField Delegate for Demo

-(BOOL)textFieldShouldReturn:(UITextField *)textField { [textField resignFirstResponder]; return YES; }

/* //This activates any buttons with a view - like make larger in the original // Example of change content view frame and then update collapseClick layout.

@end

petec029 commented 10 years ago

@david…thanks for the answer. Did not realize I could just drop a uiview into the list of components. . I tried it and sure enough it works but now I have no way of actually seeing the view in IB to lay it out. I can drag and drop controls in the list but can not actually see the view. Not much different than creating the views programatically.

daviddelmonte commented 10 years ago

I did keep the collapseCell as an external nib. So, no more code than before.

On Apr 27, 2014, at 5:45 AM, Pete Chmiel notifications@github.com wrote:

@david…thanks for the answer. Did not realize I could just drop a uiview into the list of components. . I tried it and sure enough it works but now I have no way of actually seeing the view in IB to lay it out. I can drag and drop controls in the list but can not actually see the view. Not much different than creating the views programatically.

— Reply to this email directly or view it on GitHub.

petec029 commented 10 years ago

But how did you layout the controls on the different UIViews? If you can not see the view in a storyboard then I might as well just use the xib or create the view programmatically. right?

daviddelmonte commented 10 years ago

I made nibs of each cell section. These are linked to the storyboard either through name identifiers or tags On Apr 27, 2014, at 5:53 AM, Pete Chmiel notifications@github.com wrote:

But how did you layout the controls on the different UIViews?

— Reply to this email directly or view it on GitHub.