/
InfoView.m
59 lines (48 loc) · 1.41 KB
/
InfoView.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//
// InfoView.m
// EnterTheMatrix
//
// Created by Mark Pospesel on 2/29/12.
// Copyright (c) 2012 Mark Pospesel. All rights reserved.
//
#import "InfoView.h"
#define LABEL_GAP 20
#define LABEL_WIDTH 200
@interface InfoView ()
@end
@implementation InfoView
@synthesize label;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[self.view setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"Blueprint"]]];
}
- (void)viewDidUnload
{
[self setLabel:nil];
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
} else {
return YES;
}
}
- (CGSize)contentSizeForViewInPopover
{
CGSize size = [[[self label] text] sizeWithFont:[[self label] font] constrainedToSize:CGSizeMake(LABEL_WIDTH, 480) lineBreakMode:UILineBreakModeWordWrap];
return CGSizeMake(size.width + LABEL_GAP*2, size.height + LABEL_GAP*2);
}
@end