Permalink
Browse files

Updating demo application to show dynamic remove/add right panel and …

…dynamic change center panel
  • Loading branch information...
1 parent 2feb003 commit c98524f43fd6a583af7a9917f4bad2bd763e15ae @fengjian0106 fengjian0106 committed Oct 22, 2012
@@ -34,7 +34,10 @@ @implementation JACenterViewController
- (void)viewDidLoad {
[super viewDidLoad];
- self.view.backgroundColor = [UIColor whiteColor];
+ CGFloat red = (CGFloat)arc4random() / 0x100000000;
+ CGFloat green = (CGFloat)arc4random() / 0x100000000;
+ CGFloat blue = (CGFloat)arc4random() / 0x100000000;
+ self.view.backgroundColor = [UIColor colorWithRed:red green:green blue:blue alpha:1.0f];
UILabel *label = [[UILabel alloc] init];
label.font = [UIFont boldSystemFontOfSize:20.0f];
@@ -31,5 +31,8 @@
@property (nonatomic, weak, readonly) UILabel *label;
@property (nonatomic, weak, readonly) UIButton *hide;
@property (nonatomic, weak, readonly) UIButton *show;
+@property (nonatomic, weak, readonly) UIButton *removeRightPanel;
+@property (nonatomic, weak, readonly) UIButton *addRightPanel;
+@property (nonatomic, weak, readonly) UIButton *changeCenterPanel;
@end
@@ -28,12 +28,17 @@ this software and associated documentation files (the "Software"), to deal in
#import "JASidePanelController.h"
#import "UIViewController+JASidePanel.h"
+#import "JARightViewController.h"
+#import "JACenterViewController.h"
@interface JALeftViewController ()
@property (nonatomic, weak) UILabel *label;
@property (nonatomic, weak) UIButton *hide;
@property (nonatomic, weak) UIButton *show;
+@property (nonatomic, weak) UIButton *removeRightPanel;
+@property (nonatomic, weak) UIButton *addRightPanel;
+@property (nonatomic, weak) UIButton *changeCenterPanel;
@end
@@ -69,6 +74,31 @@ - (void)viewDidLoad {
button.hidden = YES;
[self.view addSubview:button];
self.show = button;
+
+ button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
+ button.frame = CGRectMake(20.0f, 70.0f, 200.0f, 40.0f);
+ button.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin;
+ [button setTitle:@"Remove Right Panel" forState:UIControlStateNormal];
+ [button addTarget:self action:@selector(_removeRightPanelTapped:) forControlEvents:UIControlEventTouchUpInside];
+ [self.view addSubview:button];
+ self.removeRightPanel = button;
+
+ button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
+ button.frame = self.removeRightPanel.frame;
+ button.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleBottomMargin;
+ [button setTitle:@"Add Right Panel" forState:UIControlStateNormal];
+ [button addTarget:self action:@selector(_addRightPanelTapped:) forControlEvents:UIControlEventTouchUpInside];
+ button.hidden = YES;
+ [self.view addSubview:button];
+ self.addRightPanel = button;
+
+ button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
+ button.frame = CGRectMake(20.0f, 245.0f, 200.0f, 40.0f);
+ button.autoresizingMask = UIViewAutoresizingFlexibleRightMargin;
+ [button setTitle:@"Change Center Panel" forState:UIControlStateNormal];
+ [button addTarget:self action:@selector(_changeCenterPanelTapped:) forControlEvents:UIControlEventTouchUpInside];
+ [self.view addSubview:button];
+ self.changeCenterPanel = button;
}
- (void)viewWillAppear:(BOOL)animated {
@@ -109,4 +139,20 @@ - (void)_showTapped:(id)sender {
self.show.hidden = YES;
}
+- (void)_removeRightPanelTapped:(id)sender {
+ self.sidePanelController.rightPanel = nil;
+ self.removeRightPanel.hidden = YES;
+ self.addRightPanel.hidden = NO;
+}
+
+- (void)_addRightPanelTapped:(id)sender {
+ self.sidePanelController.rightPanel = [[JARightViewController alloc] init];
+ self.removeRightPanel.hidden = NO;
+ self.addRightPanel.hidden = YES;
+}
+
+- (void)_changeCenterPanelTapped:(id)sender {
+ self.sidePanelController.centerPanel = [[JACenterViewController alloc] init];
+}
+
@end
@@ -46,6 +46,10 @@ - (void)viewDidLoad {
self.hide.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleBottomMargin;
self.show.frame = self.hide.frame;
self.show.autoresizingMask = self.hide.autoresizingMask;
+
+ self.removeRightPanel.hidden = YES;
+ self.addRightPanel.hidden = YES;
+ self.changeCenterPanel.hidden = YES;
}
- (void)viewWillAppear:(BOOL)animated {

0 comments on commit c98524f

Please sign in to comment.