I basically want to use the PlacardView.m and PlacardView.h from the Apple’s MoveMe example, by adding it as a subview on my main BlowViewController
PlacardView.m
#import "PlacardView.h"
@implementation PlacardView
@synthesize placardImage;
- (id)init {
// Retrieve the image for the view and determine its size
UIImage *image = [UIImage imageNamed:@"Placard.png"];
CGRect frame = CGRectMake(0, 0, image.size.width, image.size.height);
// Set self's frame to encompass the image
self = [self initWithFrame:frame];
if (self) {
self.opaque = NO;
placardImage = image;
}
return self;
}
- (void)dealloc {
[placardImage release];
[super dealloc];
}
@end
PlacardView.h
@interface PlacardView : UIView {
UIImage *placardImage;
}
@property (nonatomic, retain) UIImage *placardImage;
// Initializer for this object
- (id)init;
@end
This is my MicBlowViewController.h
#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>
#import <CoreAudio/CoreAudioTypes.h>
@class PlacardView;
@interface MicBlowViewController : UIViewController {
AVAudioRecorder *recorder;
NSTimer *levelTimer;
double lowPassResults;
PlacardView *placardView;
}
@property(nonatomic, retain) PlacardView *placardView;
- (void)setUpPlacardView;
- (void)levelTimerCallback:(NSTimer *)timer;
@end
This is the partial MicBlowViewController.m .. there is a function viewDidLoad but that has nothing to do with the views.. its simply a timer for audio recording so I am not pasting that
#import "MicBlowViewController.h"
#import "PlacardView.h"
@implementation MicBlowViewController
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self setUpPlacardView];
}
return self;
}
- (void)setUpPlacardView {
// Create the placard view -- its init method calculates its frame based on its image
PlacardView *aPlacardView = [[PlacardView alloc] init];
self.placardView = aPlacardView;
[aPlacardView release];
placardView.center = self.center;
[self addSubview:placardView];
}
The error I get is “Property ‘center’ not found on object of type “MicBlowViewController *””
Please help.
Ayush, your code leaves me somewhat puzzled.
The code for your controller seems to have several problems.
A UIViewController does not have an
initWithFramemethod, but rather a standardinit, or aninitWithNibName:bundle:method if using an Interface Builder file.I see you have copied and pasted code from Apple’s MoveMe example, however, bear in mind that the
MoveMeViewfrom which you have copied the code into your controller is actually a UIView and not a UIViewController.Try this:
You will probably also need to implement the
loadViewmethod of yourMicBlowViewController.You may want to check out View Programming Guide, as well as UIViewController class reference.