]>
Commit | Line | Data |
---|---|---|
819a0ab1 | 1 | /* Cydia - iPhone UIKit Front-End for Debian APT |
323746d3 | 2 | * Copyright (C) 2008-2013 Jay Freeman (saurik) |
819a0ab1 JF |
3 | */ |
4 | ||
6d9696a5 | 5 | /* GNU General Public License, Version 3 {{{ */ |
819a0ab1 | 6 | /* |
6d9696a5 JF |
7 | * Cydia is free software: you can redistribute it and/or modify |
8 | * it under the terms of the GNU General Public License as published | |
9 | * by the Free Software Foundation, either version 3 of the License, | |
10 | * or (at your option) any later version. | |
819a0ab1 | 11 | * |
6d9696a5 JF |
12 | * Cydia is distributed in the hope that it will be useful, but |
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | * GNU General Public License for more details. | |
819a0ab1 | 16 | * |
6d9696a5 JF |
17 | * You should have received a copy of the GNU General Public License |
18 | * along with Cydia. If not, see <http://www.gnu.org/licenses/>. | |
19 | **/ | |
819a0ab1 JF |
20 | /* }}} */ |
21 | ||
d458596e | 22 | #include "CyteKit/ViewController.h" |
819a0ab1 JF |
23 | |
24 | #include <Foundation/Foundation.h> | |
25 | #include <UIKit/UIKit.h> | |
26 | ||
d32f96be JF |
27 | #include "iPhonePrivate.h" |
28 | ||
819a0ab1 JF |
29 | extern bool IsWildcat_; |
30 | ||
31 | @implementation UIViewController (Cydia) | |
32 | ||
33 | - (BOOL) hasLoaded { | |
34 | return YES; | |
35 | } | |
36 | ||
37 | - (void) reloadData { | |
ca629930 | 38 | [self view]; |
819a0ab1 JF |
39 | } |
40 | ||
41 | - (void) unloadData { | |
42 | if (UIViewController *modal = [self modalViewController]) | |
43 | [modal unloadData]; | |
44 | } | |
45 | ||
19f2d77f JF |
46 | - (UIViewController *) parentOrPresentingViewController { |
47 | if (UIViewController *parent = [self parentViewController]) | |
48 | return parent; | |
49 | if ([self respondsToSelector:@selector(presentingViewController)]) | |
50 | return [self presentingViewController]; | |
51 | return nil; | |
52 | } | |
53 | ||
819a0ab1 JF |
54 | @end |
55 | ||
cd79e8cf | 56 | @implementation CyteViewController |
819a0ab1 JF |
57 | |
58 | - (void) setDelegate:(id)delegate { | |
59 | delegate_ = delegate; | |
60 | } | |
61 | ||
62 | - (id) delegate { | |
63 | return delegate_; | |
64 | } | |
65 | ||
66 | - (void) viewWillAppear:(BOOL)animated { | |
67 | [super viewWillAppear:animated]; | |
68 | ||
69 | // Load on first appearance. We don't need to set the loaded flag here | |
70 | // because it is set for us the first time -reloadData is called. | |
71 | if (![self hasLoaded]) | |
72 | [self reloadData]; | |
73 | } | |
74 | ||
75 | - (BOOL) hasLoaded { | |
76 | return loaded_; | |
77 | } | |
78 | ||
79 | - (void) releaseSubviews { | |
47a40da6 | 80 | loaded_ = NO; |
819a0ab1 JF |
81 | } |
82 | ||
83 | - (void) setView:(UIView *)view { | |
84 | // Nasty hack for 2.x-compatibility. In 3.0+, we can and | |
85 | // should just override -viewDidUnload instead. | |
86 | if (view == nil) | |
87 | [self releaseSubviews]; | |
88 | ||
89 | [super setView:view]; | |
90 | } | |
91 | ||
92 | - (void) reloadData { | |
93 | [super reloadData]; | |
94 | ||
95 | // This is called automatically on the first appearance of a controller, | |
96 | // or any other time it needs to reload the information shown. However (!), | |
97 | // this is not called by any tab bar or navigation controller's -reloadData | |
98 | // method unless this controller returns YES from -hadLoaded. | |
99 | loaded_ = YES; | |
100 | } | |
101 | ||
102 | - (void) unloadData { | |
103 | loaded_ = NO; | |
104 | [super unloadData]; | |
105 | } | |
106 | ||
107 | - (NSURL *) navigationURL { | |
108 | return nil; | |
109 | } | |
110 | ||
111 | - (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orientation { | |
112 | return IsWildcat_ || orientation == UIInterfaceOrientationPortrait; | |
113 | } | |
114 | ||
81628115 JF |
115 | - (NSUInteger) supportedInterfaceOrientations { |
116 | return IsWildcat_ ? UIInterfaceOrientationMaskAll : UIInterfaceOrientationMaskPortrait; | |
117 | } | |
118 | ||
119 | - (BOOL) shouldAutorotate { | |
120 | return YES; | |
121 | } | |
122 | ||
d32f96be | 123 | - (void) setPageColor:(UIColor *)color { |
494216be | 124 | if (color == nil) |
d32f96be | 125 | color = [UIColor groupTableViewBackgroundColor]; |
494216be | 126 | color_ = color; |
d32f96be JF |
127 | } |
128 | ||
819a0ab1 | 129 | @end |