Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 111 lines (69 sloc) 4.81 kb
3c8d4e2 @coneybeare Get youtube video to work on the readme
coneybeare authored
1 What is UAModalPanel?
2 ---------------------
3
3db3821 @coneybeare Rename classes, update Readme
coneybeare authored
4 ![UAModalPanel Example Pic](http://files.urbanapps.com/images/UAModalPanel.jpg "UAModalPanel Example Pic")
5
3c8d4e2 @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 @coneybeare Rename classes, update Readme
coneybeare authored
7
8 Example Video
9 ---------------------
e18ad35 @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 @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
24 This creates new submodule, downloads the files to Submodules/UAModalPanel directory within your project and creates new commit with updated git repo settings.
25
26 Thanks to the fact that you added UAModalPanel as submodule, it is easy to keep it updated to the newest version by doing:
27
eeb018d @coneybeare Updated Readme
coneybeare authored
28 git submodule update
3db3821 @coneybeare Rename classes, update Readme
coneybeare authored
29
30
31 Step 2: Add UAModalPanel to your project
32 ------------------------------------
33
34 **Copy files from example project**
35
36 Open both the example project (that you downloaded in step 1 above) and your app's project in XCode.
37
38 Drag the UAModalPanel Group from the example project into your project's Groups & Files.
39
40 Make sure the _"Copy items into destination group's folder (if needed)"_ checkbox is _UNchecked_.
41
42 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.
43
44 **Add Frameworks**
45
46 Expand the 'Frameworks' group in your project's file list. Make sure you have the following framework installed:
47
48 * QuartzCore.framework
49
50 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.
51
52 **Base SDK and Deployment Targets**
53
54 If you aren't already, you'll want to make sure your base SDK is set to Latest iOS. You can still support older versions (back to 3.*) by setting your deployment target.
55
56 Step 3: Using UAModalPanel
57 ------------------------
58
59 **Subclass UAModalPanel**
60
61 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`
62
63 **Add UAModalPanel to a View Controller**
64
65 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.
66
67 @class UAModalPanel;
68 @interface UAViewController : UIViewController {
69 UAModalPanel *currentPanel;
70 }
71 @property (nonatomic, retain) UAModalPanel *currentPanel;
72
30e5071 @coneybeare Updated Readme
coneybeare authored
73 In your .m file, synthesize and dealloc the panel
3db3821 @coneybeare Rename classes, update Readme
coneybeare authored
74
75 @synthesize currentPanel;
76 - (void)dealloc {
77 self.currentPanel = nil;
78 [super dealloc];
79 }
80
81 Display the panel by creating an instance of your subclass and show it from a point:
82
83 - (IBAction)showModalPanel:(id)sender {
84
85 self.currentPanel = [[[UAExampleModalPanel alloc] initWithFrame:self.view.bounds title:[(UIButton *)sender titleForState:UIControlStateNormal]] autorelease];
86
87 self.currentPanel.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
88 self.currentPanel.autoresizesSubviews = YES;
89 self.currentPanel.delegate = self;
90 self.currentPanel.margin = 20.0f;
91 self.currentPanel.shouldBounce = YES;
92
93 [self.view addSubview:self.currentPanel];
94 [self.currentPanel showFromPoint:[sender center]];
95 }
96
97 You must also implement the delegate method for when the close button is pressed:
98
99 - (void)removeModalView {
100 [self.currentPanel hideWithDelegate:self selector:@selector(removeModal)];
101 }
102
103 ... and for when the close animations are completed:
104
105 - (void)removeModal {
106 [self.currentPanel removeFromSuperview];
107 self.currentPanel = nil;
108 }
109
110
111 That's it. Please feel free to fork and submit pull requests, fix issues or whatever else.
Something went wrong with that request. Please try again.