Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Storyboard? #5

Open
svaz opened this issue Mar 29, 2013 · 10 comments
Open

Storyboard? #5

svaz opened this issue Mar 29, 2013 · 10 comments

Comments

@svaz
Copy link

svaz commented Mar 29, 2013

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

@bennyguitar
Copy link
Owner

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

@ryanmsusa
Copy link

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

@farazhaider88
Copy link

is there any way to use it using storyboard?

@petec029
Copy link

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
Copy link

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
Copy link

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;

  • (void)viewDidLoad
    {
    [super viewDidLoad];
    item.text = @"try this";
    category.text = @"Home";
    date1.text = @"todays date";
    date2.text = @"another date";
    serial.text = @"serial no";

    itemArray = [[NSMutableArray alloc] initWithObjects:item,category, date1, date2,serial, nil];

    NSLog(@"itemArray: %@", itemArray);

    myCollapseClick.CollapseClickDelegate = self;
    [myCollapseClick reloadCollapseClick];

    // If you want a cell open on load, run this method:
    //[myCollapseClick openCollapseClickCellAtIndex:1 animated:NO];

    /*
    // If you'd like multiple cells open on load, create an NSArray of NSNumbers
    // with each NSNumber corresponding to the index you'd like to open.
    // - This will open Cells at indexes 0,2 automatically

    NSArray *indexArray = @[[NSNumber numberWithInt:0],[NSNumber numberWithInt:2]];
    [myCollapseClick openCollapseClickCellsWithIndexes:indexArray animated:NO];
    */
    }

  • (void)didReceiveMemoryWarning
    {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
    }

#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.

  • (IBAction)buttonClicked:(id)sender {
    NSLog(@"button clicked");

    itemView.frame = CGRectMake(0, 0, itemView.frame.size.width, itemView.frame.size.height + 50);
    [myCollapseClick setNeedsLayout];
    }
    */

@EnD

@petec029
Copy link

@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
Copy link

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 [email protected] 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
Copy link

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
Copy link

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 [email protected] wrote:

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


Reply to this email directly or view it on GitHub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants