PaperFold-for-iOS icon indicating copy to clipboard operation
PaperFold-for-iOS copied to clipboard

any luck with IB/Storyboard for defining views?

Open randyarrowood opened this issue 14 years ago • 15 comments

first, love the fold control... can't wait to use it.

i'm trying to figure out how to use my existing project defined using IB/Storyboard for each view and it is crashing when trying to setRightFoldContentView. i think it's because the view is already added as a subview. i've tried removing from superview first, but still crashes/traps.

the exact errors are:
: CGContextSaveGState: invalid context 0x0 : CGContextRestoreGState: invalid context 0x0 : CGContextSetBaseCTM: invalid context 0x0 CGContextSetBaseCTM: invalid context 0x0 CGContextClipToRect: invalid context 0x0

coming from MultiFoldView.m in setScreenshotImage on the CFRelease(imageRef)

randyarrowood avatar Nov 14 '12 17:11 randyarrowood

i think i got it...

I changed the AppDelegate.m to have:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{    
    RightViewController *rvc = [self.window.rootViewController.storyboard instantiateViewControllerWithIdentifier:@"rightViewID"];
    LeftViewController *lvc = [self.window.rootViewController.storyboard instantiateViewControllerWithIdentifier:@"leftViewID"];
    PaperFoldNavigationController *paperFoldNavController = [[PaperFoldNavigationController alloc] initWithRootViewController:self.window.rootViewController];
    [self.window setRootViewController:paperFoldNavController];

    [paperFoldNavController setLeftViewController:lvc width:150];
    [paperFoldNavController setRightViewController:rvc width:320.0 rightViewFoldCount:3 rightViewPullFactor:0.9];

    return YES;
}

randyarrowood avatar Nov 15 '12 05:11 randyarrowood

So this is working now? Thanks for letting me know.

honcheng avatar Nov 20 '12 09:11 honcheng

yes... great control... thanks

randyarrowood avatar Nov 20 '12 15:11 randyarrowood

Thanks

honcheng avatar Nov 20 '12 23:11 honcheng

I subclassed nav controller to set side view controllers, view widths, and fold counts in IB interconnecting in storyboards them with custom segues. It probably wouldn't be too hard to encapsulate top and bottom folds too.

texastoland avatar Dec 22 '12 18:12 texastoland

Hi, I really cant get PaperFold to work with storyboard. Any help or a tutorial would be great!

Thanks in advance, Luca

lucalodi avatar Jan 26 '13 02:01 lucalodi

Which class are you using and what problem are you running into?

texastoland avatar Jan 26 '13 03:01 texastoland

I have a blank project just to test and build a solid prototype before implement into my def app. So my setup: storyboard with 2 tab and navigation control.

Now how can I implement PaperFold to whole app and slide a view from storyboard?

lucalodi avatar Jan 26 '13 03:01 lucalodi

  • Subclass PaperFoldNavigationController
  • Add properties like @property (nonatomic, copy, readonly) NSString *rootViewControllerID, *leftViewControllerID, *rightViewControllerID;
  • Override -awakeFromNib like:
- (void)awakeFromNib {
  [super awakeFromNib];
  if (self.rootViewControllerID) {
    self.rootViewController = [self.storyboard instantiateViewControllerWithIdentifier:self.rootViewControllerID];
  }
  if (self.leftViewControllerID) {
    self.leftViewController = [self.storyboard instantiateViewControllerWithIdentifier:self.leftViewControllerID];
  }
  if (self.rightViewControllerID) {
    self.rightViewController = [self.storyboard instantiateViewControllerWithIdentifier:self.rightViewControllerID];
  }
}
  • Give the view controllers you want to embed Storyboard IDs
  • Add your custom PaperFoldNavigationController to the storyboard
  • Add User Defined Runtime Attributes linking your Storyboard IDs to your custom properties

This should get you mostly working?

@honcheng Would you be interested in a PR to improve storyboard integration?

texastoland avatar Jan 26 '13 04:01 texastoland

Hi Jonathan,

What do you mean by PR?

On 26 Jan, 2013, at 12:34 PM, Jonathan Toland [email protected] wrote:

Subclass PaperFoldNavigationController Add properties like @property (nonatomic, copy, readonly) NSString *rootViewControllerID, *leftViewControllerID, *rightViewControllerID; Override -awakeFromNib like:

  • (void)awakeFromNib { [super awakeFromNib]; if (self.rootViewControllerID) { self.rootViewController = [self.storyboard instantiateViewControllerWithIdentifier:self.rootViewControllerID]; } if (self.leftViewControllerID) { self.leftViewController = [self.storyboard instantiateViewControllerWithIdentifier:self.leftViewControllerID]; } if (self.rightViewControllerID) { self.rightViewController = [self.storyboard instantiateViewControllerWithIdentifier:self.rightViewControllerID]; } } Give the view controllers you want to embed Storyboard IDs Add your custom PaperFoldNavigationController to the storyboard Add User Defined Runtime Attributes linking your Storyboard IDs to your custom properties This should get you mostly working?

@honcheng Would you be interested in a PR to improve storyboard integration?

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

honcheng avatar Jan 26 '13 09:01 honcheng

@honcheng Pull Request :neckbeard: I didn't know if you'd prefer to keep PaperfoldNavigationController simple. I also think PaperfoldMenuController should extend it. @lucalodi Any luck?

texastoland avatar Jan 26 '13 15:01 texastoland

hello guys, having a little trouble trying to get it going into storyboard

rlove1221 avatar Mar 03 '13 17:03 rlove1221

Hey guys - can anybody post up there working version of this with storyboards? I've tried countless times to get this working with my storyboards, but it just isn't working. Any help would be GREATLY appreciated! :)

seanherman avatar Mar 18 '13 01:03 seanherman

Hello ,i'm still having a little trouble as well . Would love to get some help also.

On Mar 17, 2013, at 9:13 PM, seanherman [email protected] wrote:

Hey guys - can anybody post up there working version of this with storyboards? I've tried countless times to get this working with my storyboards, but it just isn't working. Any help would be GREATLY appreciated! :)

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

rlove1221 avatar Mar 18 '13 14:03 rlove1221

why the content of left and right didn't appear while I see in the log that the views opened

amroelsherif avatar Jul 27 '13 22:07 amroelsherif