Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 110 lines (69 sloc) 4.95 kb
3c8d4e2 Matt Coneybeare Get youtube video to work on the readme
coneybeare authored
1 What is UAModalPanel?
2 ---------------------
3
ada805f Matt Coneybeare Updated the README, Organize project files
coneybeare authored
4 ![UAModalPanel Example Pic](http://files.urbanapps.com/images/UAModalPanel.jpg "UAModalPanel Example Pic") ![UAModalPanel Example Pic 2](http://files.urbanapps.com/images/UAModalPanel2.jpg "UAModalPanel Example Pic 2")
3db3821 Matt Coneybeare Rename classes, update Readme
coneybeare authored
5
3c8d4e2 Matt Coneybeare Get youtube video to work on the readme
coneybeare authored
6 `UAModalPanel` is an alternative modal panel that you can popup in your view controllers to show content that might not need an entire new screen to show. It works on the iPhone and iPad, with or without rotation, and is a non-ARC project.
3db3821 Matt Coneybeare Rename classes, update Readme
coneybeare authored
7
8 Example Video
9 ---------------------
e18ad35 Matt Coneybeare Changed example URL, update Readme
coneybeare authored
10 I can't figure out how to embed a video in markdown, so here is a link to it: http://www.youtube.com/watch?v=AJDR0GAsV9E
3db3821 Matt Coneybeare Rename classes, update Readme
coneybeare authored
11
12
13 Step 0: Prerequisites
14 ---------------------
15 You'll need at least XCode 3.2.
16
17 Step 1: Get UAModalPanel files (add as Git submodule)
18 ----------------
19 In terminal navigate to the root of your project directory and run these commands (assuming your project is a git repo):
20
21 git submodule add git://github.com/coneybeare/UAModalPanel.git Submodules/UAModalPanel
22 git commit -m 'UAModalPanel added as submodule'
23
ada805f Matt Coneybeare Updated the README, Organize project files
coneybeare authored
24 This creates new submodule, downloads the files to Submodules/UAModalPanel directory within your project and creates new commit with updated git repo settings. Thanks to the fact that you added UAModalPanel as submodule, it is easy to keep it updated to the newest version by simply doing:
3db3821 Matt Coneybeare Rename classes, update Readme
coneybeare authored
25
eeb018d Matt Coneybeare Updated Readme
coneybeare authored
26 git submodule update
3db3821 Matt Coneybeare Rename classes, update Readme
coneybeare authored
27
28
29 Step 2: Add UAModalPanel to your project
30 ------------------------------------
31
32 **Copy files from example project**
33
ada805f Matt Coneybeare Updated the README, Organize project files
coneybeare authored
34 * Open both the example project (that you downloaded in step 1 above) and your app's project in XCode.
35 * Drag the UAModalPanel Group from the example project into your project's Groups & Files.
36 * Make sure the _"Copy items into destination group's folder (if needed)"_ checkbox is _UNchecked_.
3db3821 Matt Coneybeare Rename classes, update Readme
coneybeare authored
37
38 XCode 4 note: adding the files is different in Xcode 4 - first, make sure your UAModalPanel project window is closed, then you drag the UAModalPanel.xcodeproj file (from a Finder window) to your project. You should see the UAModalPanel's proj tree open up within your project in XCode, and then you should be able to drag UAModalPanel group as stated above. You then **must remove UAModalPanel.xcodeproj (whole UAModalPanel project) from your project**, so that it does not interfere with your project.
39
40 **Add Frameworks**
41
42 Expand the 'Frameworks' group in your project's file list. Make sure you have the following framework installed:
43
44 * QuartzCore.framework
45
46 If you are missing any frameworks, right click the 'Frameworks' group and select Add -> Existing Frameworks. Select the framework you are missing and add it to your project.
47
48
49 Step 3: Using UAModalPanel
50 ------------------------
51
52 **Subclass UAModalPanel**
53
54 The best way to use the panel is to subclass it and add your own elements to the `contentView`. To get a plain modal panel, subclass `UAModalPanel`. To get a titled modal panel, subclass `UATitledModalPanel`. Check out the example project for a sample subclass, `UAExampleModalPanel`
55
56 **Add UAModalPanel to a View Controller**
57
58 In your `.h` file, keep an instance variable to the panel. This allows your controller to communicate with the panel if necessary, and to close it when done.
59
60 @class UAModalPanel;
61 @interface UAViewController : UIViewController {
62 UAModalPanel *currentPanel;
63 }
3074094 Matt Coneybeare Updated Readme
coneybeare authored
64 @property (nonatomic, retain) UAModalPanel *currentPanel;
3db3821 Matt Coneybeare Rename classes, update Readme
coneybeare authored
65
30e5071 Matt Coneybeare Updated Readme
coneybeare authored
66 In your .m file, synthesize and dealloc the panel
3db3821 Matt Coneybeare Rename classes, update Readme
coneybeare authored
67
68 @synthesize currentPanel;
69 - (void)dealloc {
70 self.currentPanel = nil;
71 [super dealloc];
72 }
73
74 Display the panel by creating an instance of your subclass and show it from a point:
75
76 - (IBAction)showModalPanel:(id)sender {
ada805f Matt Coneybeare Updated the README, Organize project files
coneybeare authored
77
3074094 Matt Coneybeare Updated Readme
coneybeare authored
78 self.currentPanel = [[[UAExampleModalPanel alloc] initWithFrame:self.view.bounds title:[(UIButton *)sender titleForState:UIControlStateNormal]] autorelease];
79
80 self.currentPanel.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
81 self.currentPanel.autoresizesSubviews = YES;
82 self.currentPanel.delegate = self;
3d0137f Matt Coneybeare Updated Readme
coneybeare authored
83 self.currentPanel.margin = 20.0f;
3074094 Matt Coneybeare Updated Readme
coneybeare authored
84 self.currentPanel.shouldBounce = YES;
3d0137f Matt Coneybeare Updated Readme
coneybeare authored
85
3074094 Matt Coneybeare Updated Readme
coneybeare authored
86 [self.view addSubview:self.currentPanel];
87 [self.currentPanel showFromPoint:[sender center]];
3db3821 Matt Coneybeare Rename classes, update Readme
coneybeare authored
88 }
89
90 You must also implement the delegate method for when the close button is pressed:
91
92 - (void)removeModalView {
93 [self.currentPanel hideWithDelegate:self selector:@selector(removeModal)];
94 }
95
96 ... and for when the close animations are completed:
97
98 - (void)removeModal {
99 [self.currentPanel removeFromSuperview];
3074094 Matt Coneybeare Updated Readme
coneybeare authored
100 self.currentPanel = nil;
3db3821 Matt Coneybeare Rename classes, update Readme
coneybeare authored
101 }
102
103
6869e78 Matt Coneybeare Updated Readme
coneybeare authored
104 That's it. Please feel free to fork and submit pull requests, fix issues or whatever else.
105
6aefb3d Matt Coneybeare Updated Readme
coneybeare authored
106
107 * 13k reputation on Stack Overflow: http://stackoverflow.com/users/69634/coneybeare
108 * Follow my code blog: http://code.coneybeare.net
4633d84 Matt Coneybeare Updated Readme
coneybeare authored
109 * Contact me on Twitter: http://twitter.com/coneybeare
Something went wrong with that request. Please try again.