]> git.saurik.com Git - cydia.git/blame - CyteKit/ViewController.mm
Try harder to block all iTunes-related redirects.
[cydia.git] / CyteKit / ViewController.mm
CommitLineData
819a0ab1 1/* Cydia - iPhone UIKit Front-End for Debian APT
6fa0bb60 2 * Copyright (C) 2008-2014 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@implementation UIViewController (Cydia)
30
31- (BOOL) hasLoaded {
32 return YES;
33}
34
35- (void) reloadData {
ca629930 36 [self view];
819a0ab1
JF
37}
38
39- (void) unloadData {
40 if (UIViewController *modal = [self modalViewController])
41 [modal unloadData];
42}
43
19f2d77f
JF
44- (UIViewController *) parentOrPresentingViewController {
45 if (UIViewController *parent = [self parentViewController])
46 return parent;
47 if ([self respondsToSelector:@selector(presentingViewController)])
48 return [self presentingViewController];
49 return nil;
50}
51
819a0ab1
JF
52@end
53
cd79e8cf 54@implementation CyteViewController
819a0ab1
JF
55
56- (void) setDelegate:(id)delegate {
57 delegate_ = delegate;
58}
59
60- (id) delegate {
61 return delegate_;
62}
63
64- (void) viewWillAppear:(BOOL)animated {
65 [super viewWillAppear:animated];
66
67 // Load on first appearance. We don't need to set the loaded flag here
68 // because it is set for us the first time -reloadData is called.
69 if (![self hasLoaded])
70 [self reloadData];
71}
72
73- (BOOL) hasLoaded {
74 return loaded_;
75}
76
77- (void) releaseSubviews {
47a40da6 78 loaded_ = NO;
819a0ab1
JF
79}
80
81- (void) setView:(UIView *)view {
82 // Nasty hack for 2.x-compatibility. In 3.0+, we can and
83 // should just override -viewDidUnload instead.
84 if (view == nil)
85 [self releaseSubviews];
86
87 [super setView:view];
88}
89
90- (void) reloadData {
91 [super reloadData];
92
93 // This is called automatically on the first appearance of a controller,
94 // or any other time it needs to reload the information shown. However (!),
95 // this is not called by any tab bar or navigation controller's -reloadData
96 // method unless this controller returns YES from -hadLoaded.
97 loaded_ = YES;
98}
99
100- (void) unloadData {
101 loaded_ = NO;
102 [super unloadData];
103}
104
105- (NSURL *) navigationURL {
106 return nil;
107}
108
d32f96be 109- (void) setPageColor:(UIColor *)color {
494216be 110 if (color == nil)
d32f96be 111 color = [UIColor groupTableViewBackgroundColor];
494216be 112 color_ = color;
d32f96be
JF
113}
114
3da96c86
JF
115#include "InterfaceOrientation.h"
116
819a0ab1 117@end