NSStream Released while reading in, "EXC_BAD_ACCESS" iPhone SDK - iphone

I have a view controller that is an NSStreamDelegate, I have a problem when the view is popped from the navigation controller while something is being streamed I get a "EXC_BAD_ACCESS" error. I have tried closing the stream, but it doesn't seem to stop it if there is a stream in progress. What is the proper way to handle this, can you delay the view from popping if something is being streamed?
#import "CameraViewer.h"
#implementation CameraViewer
#synthesize camService;
#synthesize currentDownload;
// The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil theService:(NSNetService *)cameraService {
if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
// Custom initialization
[self setCamService:cameraService];
}
return self;
}
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
[self downloadAgain];
}
- (void)viewWillDisappear:(BOOL)animated{
NSLog(#"view is going away");
NSInputStream *istream;
[camService getInputStream:&istream outputStream:nil];
[istream close];
NSLog(#"view is gone");
[super viewWillDisappear:animated];
}
- (void)downloadAgain{
NSInputStream *istream;
[camService getInputStream:&istream outputStream:nil];
[istream retain];
[istream setDelegate:self];
[istream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
[istream open];
}
#pragma mark NSStream delegate method
- (void)stream:(NSStream *)aStream handleEvent:(NSStreamEvent)event {
switch(event) {
case NSStreamEventHasBytesAvailable:
NSLog(#"Reading Stream");
if (![self currentDownload]) {
[self setCurrentDownload:[[NSMutableData alloc] initWithCapacity:409600]];
}
uint8_t readBuffer[4096];
int amountRead = 0;
NSInputStream * is = (NSInputStream *)aStream;
amountRead = [is read:readBuffer maxLength:4096];
[[self currentDownload] appendBytes:readBuffer length:amountRead];
//NSLog(#"case 1");
break;
case NSStreamEventEndEncountered:
[(NSInputStream *)aStream close];
UIImage *newImage = [[UIImage alloc] initWithData:[self currentDownload]];
[self setCurrentDownload:nil];
if(newImage != nil){
[imageView setImage:newImage];
}
[newImage release];
[self performSelector:#selector(downloadAgain) withObject:nil afterDelay:0.25];
break;
default:
break;
}
}
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[[self camService] release];
[[self currentDownload] release];
[super dealloc];
}
#end

I see that you call scheduleInRunLoop. In that case, when you don't need the stream, you should also call
[istream removeFromRunLoop:[NSRunLoop currentRunLoop]
forMode: NSDefaultRunLoopMode];
after you've closed the stream.

What is happening is whatever instance of the CameraViewer class (which is set to be the delegate) is being deallocated (causing EXC_BAD_ACCESS in the run loop) because you didn't retain it.
The solution is to either call retain on the CameraViewer class at instantiation, like so:
CameraViewer *cameraViewer = [[CameraViewer alloc] init];
[cameraViewer retain];

Related

Core data random crash

I finished the development of my app but at this point I face random crashes when I try to save an image in core data.
Here is the console message:
CoreData: error: Serious application error. Exception was caught
during Core Data change processing. This is usually a bug within an
observer of NSManagedObjectContextObjectsDidChangeNotification.
-[_PFExternalReferenceData compare:]: unrecognized selector sent to instance 0x94b69b0 with userInfo (null)
The problem is that it is non deterministic. It happens more or less once out of 5 times.
Would anyone have an idea where I should look for ?
EDIT:
Here is the code of my class that seems to pose a problem. It happens sometimes when I click on the save button, calling -(IBAction)saveResultingImage:
#import "ResultViewController.h"
#interface ResultViewController ()
#property (nonatomic)BOOL resultSaved;
#end
#implementation ResultViewController
#pragma mark - IBActions
- (IBAction)saveResultingImage
{
UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, NO, 0.0);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
_resultImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
_resultSaved = [self saveOnCoreData];
[self performSegueWithIdentifier:#"BackToStartSegue" sender:self];
}
- (IBAction)discardWithoutSaving
{
[self performSegueWithIdentifier:#"BackToStartSegue" sender:self];
}
- (IBAction)restartDrawing:(id)sender
{
UIImage *backgroundImage = _subImage;
UIImageView *imageView =
[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, backgroundImage.size.width, backgroundImage.size.height)];
imageView.image = backgroundImage;
[self.view addSubview:imageView];
UIImage *maskImage = _maskImage;
CGRect maskViewRect = CGRectMake(0, 0, maskImage.size.width, maskImage.size.height);
ImageMaskView *subView = [[ImageMaskView alloc] initWithFrame:maskViewRect image:maskImage];
[self.view addSubview:subView];
}
- (IBAction)showExplainVC
{
[self performSegueWithIdentifier:#"ShowInfoSegue" sender:self];
}
#pragma mark - Methods
- (BOOL)saveOnCoreData
{
NSManagedObjectContext *context = [self managedObjectContext];
NSManagedObject *newMeme =
[NSEntityDescription insertNewObjectForEntityForName:#"Meme" inManagedObjectContext:context];
NSData *toSaveMeme = UIImagePNGRepresentation(_resultImage);
[newMeme setValue:toSaveMeme forKey:#"image"];
NSError *error = nil;
if (![context save:&error]) {
DebugLog(#"Can't save: %# %#", error, [error localizedDescription]);
return NO;
}
return YES;
}
#pragma mark - View Controller LifeCycle
- (BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender
{
if ([identifier isEqualToString:#"BackToStartSegue"]) {
return _resultSaved;
}
return _resultSaved;
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self.navigationController setNavigationBarHidden:NO];
DebugLog(#"Called viewWillAppear");
self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
UIBarButtonItem *discardBarButtonItem =
[[UIBarButtonItem alloc] initWithTitle:#"Discard" style:UIBarButtonItemStylePlain target:self action:#selector(discardWithoutSaving)];
UIBarButtonItem *saveBarButtonItem =
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave target:self action:#selector(saveResultingImage)];
UIBarButtonItem *infoBarButton =
[[UIBarButtonItem alloc] initWithTitle:#"How to" style:UIBarButtonItemStylePlain target:self action:#selector(showExplainVC)];
discardBarButtonItem.style = UIBarButtonItemStyleBordered;
self.navigationItem.rightBarButtonItems = #[saveBarButtonItem, discardBarButtonItem, infoBarButton];
self.view.backgroundColor = [UIColor blackColor];
[self restartDrawing:nil];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Core Data Stack
- (NSManagedObjectContext *)managedObjectContext
{
NSManagedObjectContext *context = nil;
id delegate = [[UIApplication sharedApplication] delegate];
if ([delegate performSelector:#selector(managedObjectContext)]) {
context = [delegate managedObjectContext];
}
return context;
}
#end
Thanks for showing interest :-)

New instance of a UIViewController within another UIViewController: Why can't I set an instance variable?

So I have a UIViewController subclass called MyTabBarViewController that has a UIScrollView. Inside of MyTabBarViewController I'm creating an instance of another UIViewController subclass called PhotoViewController. (Note: I'm doing this so I can set up the IBOutlets using IB)
I'm trying to set the label of each PhotoViewController instance from my TabBarViewController. And I init with nib for each PhotoViewController so I was under the impression that each PhotoViewController instance would be wired up to their respective IBOutlets - allowing me to simply set the label name using pvc.label.text = #"text I want".
Could you explain why my logic is incorrect? Because it's not working and not really sure what to do. :-/
MyTabBarViewController.m
#import "MyTabBarViewController.h"
#implementation MyTabBarViewController
#synthesize pageControl,scroller;
-(IBAction)clickPageControl:(id)sender
{
int page=pageControl.currentPage;
CGRect frame=scroller.frame;
frame.origin.x = frame.size.width * page;
frame.origin.y = 0;
[scroller scrollRectToVisible:frame animated:YES];
}
-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
int page = scrollView.contentOffset.x/scrollView.frame.size.width;
pageControl.currentPage=page;
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)dealloc
{
[super dealloc];
}
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
scroller.delegate=self;
scroller.pagingEnabled=YES;
scroller.directionalLockEnabled=YES;
scroller.showsHorizontalScrollIndicator=NO;
scroller.showsVerticalScrollIndicator=NO;
scroller.contentSize=CGSizeMake(pageControl.numberOfPages*scroller.frame.size.width, scroller.frame.size.height);
CGFloat scrollWidth = 0;
int pageNumber = 0;
for (int i=0; i<3; i++)
{
PhotoViewController *pvc = [[PhotoViewController alloc] initWithNibName:#"PhotoViewController" bundle:nil];
CGRect rect = scroller.frame;
rect.size.height = scroller.frame.size.height;
rect.size.width = scroller.frame.size.width;
rect.origin.x = scroller.frame.origin.x + scrollWidth;
rect.origin.y = scroller.frame.origin.y;
pvc.label.text = [NSString stringWithFormat:#"%d", pageNumber];
pvc.label.textColor = [UIColor redColor];
pvc.view.frame = rect;
[scroller addSubview:pvc.view];
[pvc release];
pageNumber++;
scrollWidth += scroller.frame.size.width;
}
pageControl.numberOfPages=3;
pageControl.currentPage=0;
[self.view addSubview:scroller];
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
#end
PhotoViewController.h is pretty straight-forward. And PhotoViewController.m is too but I've included the implementation file in the event that my problem is in there.
PhotoViewController.m
#import "PhotoViewController.h"
#implementation PhotoViewController
#synthesize label, imageView, sendButton, cancelButton;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)dealloc
{
[super dealloc];
}
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
#end
You cant set any view related values like this(making object and set other enteries from that view).
Because you can't set any level's value before viewDidLoad of any view controller.What you need, you need set properties of string type for labels accordingly and set their values in MyTabBarViewController then from the stack pick up the object of the MyTabBarViewController class in PhotoViewController and then access it's properties and set your labels.
For picking the view object from stack you need to use this line
MyTabBarViewController *obj = (MyTabBarViewController *)[self.navigationController.viewControllers objectAtIndex: [self.navigationController.viewControllers count]-2];
The IBOutlet entities don't exist until viewDidLoad, and that doesn't generally happen until you initiate a show. Therefore, in MyTabBarViewController you're addressing a label, et al, that doesn't exist. (Of course, Objective-C conveniently ignores calls on nil pointers, so it SEEMS like it all works -- just nothing happens.)
According to the spec, you can trigger loading by referring to the view property of the view controller, but I've never tried it.

add a countdown, display the time and fire an action

Hi I am a beginner in programming
I have already created a tapping application, displaying the tap count after pressing the result button
I want to add a NSTimer, counting 30 second after the first tap (after the tap button was pressed for the first time).
at the same time, displaying the time count down on a label (UILabel timeLabel)
and after 30 second, the tap count will restart to 0.
Please kindly tell me if I need to post anything other than the following, Thanks!!
Here is my .h file
#import <UIKit/UIKit.h>
#import <AVFoundation/AVAudioPlayer.h>
#import <AudioToolbox/AudioToolbox.h>
#class Player;
#interface Tapping2ViewController : UIViewController
<AVAudioPlayerDelegate>
{
Player *aPlayer;
IBOutlet UILabel *timerLabel;
IBOutlet UILabel *resultLabel;
AVAudioPlayer *buttonPlayer;
NSTimer *lv1Timer;
NSInteger *counter1;
}
- (IBAction)addTap:(id)sender;
- (IBAction)getResult:(id)sender;
-(void)restartTapCount;
-(void)start;
#property (retain) NSTimer *lv1Timer;
#property (nonatomic, retain) IBOutlet UILabel *timerLabel;
#end
and my .M file
#import "Tapping2ViewController.h"
#import "Player.h"
#implementation Tapping2ViewController
#synthesize lv1Timer;
#synthesize timerLabel;
- (id) initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil
bundle:nibBundleOrNil];
if (self) {
}
return self;
}
- (void)dealloc
{
[resultLabel release];
[lv1Timer release];
[aPlayer release];
[timerLabel release];
[super dealloc];
}
- (void)didReceiveMemoryWarning
{
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
aPlayer = [[Player alloc] init];
[super viewDidLoad];
}
- (IBAction)addTap:(id)sender
{
//呢到係設定聲音, 首先要用NSSTRING 去 SET 左條路徑先
NSString *buttonFile = [[NSBundle mainBundle] pathForResource:#"button" ofType:#"wav"];
//之後再條NSSTRING 轉做NSURL (因為AVPLAYER 只認URL)
NSURL *buttonFileURL = [NSURL fileURLWithPath:buttonFile];
NSError *error = nil;
//設定AUDIO PLAYER 要播邊條 聲音 *記得SET DELEGATE 做自已去執行
buttonPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:buttonFileURL error:&error];
[buttonPlayer setDelegate:self];
NSLog(#"Before: %d", aPlayer.tapCount);
aPlayer.tapCount++;
//呼叫播放既METHOD
[buttonPlayer play];
NSLog(#"After: %d", aPlayer.tapCount);
/*
//即時顯示數字
aPlayer.result = aPlayer.tapCount;
NSString *sResult = [NSString stringWithFormat:#"%D", aPlayer.result];
resultLabel.text = sResult;
*/
}
- (IBAction)getResult:(id)sender {
aPlayer.result = aPlayer.tapCount;
NSString *aResult = [NSString stringWithFormat:#"%D", aPlayer.result];
resultLabel.text = aResult;
}
-(void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
if (motion == UIEventSubtypeMotionShake)
{
aPlayer.tapCount = 0;
resultLabel.text = #"0";
}
}
- (void)viewDidUnload
{
[resultLabel release];
resultLabel = nil;
[timerLabel release];
timerLabel = nil;
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
//下面係PART OF DETECT SHAKE 既METHOD
-(BOOL)canBecomeFirstResponder
{
return YES;
}
-(void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[self becomeFirstResponder];
}
-(void)viewWillDisappear:(BOOL)animated
{
[self resignFirstResponder];
[super viewWillDisappear:animated];
}
//去到呢到都係
#end
Here is how I do it in an app, on start :
count = COUNTDOWN_DURATION;
countdownTimer = [NSTimer scheduledTimerWithTimeInterval:1
target:self selector:#selector(countDown)
userInfo:nil repeats:YES];
this will call a countDown method every second. Do whatever you want in that countDown method but make sure to stop the NSTimer on completion (and of course to decrement counter):
if (count < 0) {
[countdownTimer invalidate];
countdownTimer = nil;
}
...
count--;

iphone, if I can' populate in the thread function, how can i exit?

I've added my database populate code to the thread method. However, sometimes they may not be any data to show in the graph. I don't want to run the query twice, once before to check if theres any data and I don't want to pre-populate the graph points prior to the thread function.
I've marked where I have my populate code with HERE below.
I think my only option is to exit the thread function, but I'm a little concerned and I want to do this correctly, what do i need to do ?
#import "GraphController.h"
#implementation GraphPoint
- (id) initWithID:(int)pkv value:(NSNumber*)number{
if(self = [super init]){
pk = pkv;
value = [number retain];
}
return self;
}
- (NSNumber*) yValue{
return value;
}
- (NSString*) xLabel{
return [NSString stringWithFormat:#"%d",pk];
}
- (NSString*) yLabel{
return [NSString stringWithFormat:#"%d",[value intValue]];
}
#end
#implementation GraphController
- (void)viewDidLoad{
[super viewDidLoad];
graph.title.text = #"Graph View";
[graph setPointDistance:15];
indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
CGRect r = indicator.frame;
r.origin = self.view.bounds.origin;
r.origin.x = self.view.bounds.size.width / 2 - r.size.width / 2;
r.origin.y = self.view.bounds.size.height / 2 - r.size.height / 2;
indicator.frame = r;
[self.view addSubview:indicator];
[indicator startAnimating];
data = [[NSMutableArray alloc] init];
[NSThread detachNewThreadSelector:#selector(thread) toTarget:self withObject:nil];
}
- (void) thread{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
//HERE
srand([[NSDate date] timeIntervalSince1970]);
for(int i=0;i<100;i++){
int no = rand() % 100 + i;
GraphPoint *gp = [[GraphPoint alloc] initWithID:i value:[NSNumber numberWithFloat:no]];
[data addObject:gp];
[gp release];
}
[self performSelectorOnMainThread:#selector(threadComplete) withObject:nil waitUntilDone:NO];
[pool drain];
}
- (void) threadComplete{
[indicator stopAnimating];
[self.graph setGraphWithDataPoints:data];
self.graph.goalValue = [NSNumber numberWithFloat:30.0];
self.graph.goalShown = YES;
[self.graph scrollToPoint:80 animated:YES];
[self.graph showIndicatorForPoint:75];
}
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[data release];
[indicator release];
[super dealloc];
}
#end
I'm using Tapku Graph http://duivesteyn.net/2010/03/07/iphone-sdk-implementing-the-tapku-graph-in-your-application/?utm_source=twitterfeed&utm_medium=twitter
To close the thread, just return from the thread method. But don't forget to call [pool release]; (please use it instead of [pool drain]; at the end of your method as well; on iOS where there's no GC they are the same but if Apple one day decides to add GC support they're different).
So it's something like this:
if (wantToCloseThread) {
// Release everything we've allocated.
[pool release];
// Also, if you alloc'ed something that is not autoreleased
// you should release it here.
return;
}
An alternative is to use goto (yes, its use for this is OK):
- (void) thread {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
...
if (something)
goto out;
...
if (somethingElse)
goto out;
...
out:
// Cleanup.
[pool release];
// Also, if you alloc'ed something that is not autoreleased
// you should release it here.
}
This way, you have to write the cleanup only once and the goto ensures that every time you want to actually leave the thread, the complete cleanup is done.

Problem with Landscape and Portrait view in a TabBar Application

I have an TabBar app that I would like to be in landscape and portrait. The issue is when I go to tab 2 make a selection from my table then select tab 1 and rotate the device, then select tab 2 again the content does not know that the device rotated and will not display my custom orientated content correctly. I am trying to write a priovate method that tells the view what orientation it is currently in. IN viewDidLoad I am assuming it is in portrait but in shouldAutoRotate I have it looking in the private method for the correct alignment of the content. Please Help!! Here is my code:
#import "DetailViewController.h"
#import "ScheduleTableViewController.h"
#import "BrightcoveDemoAppDelegate.h"
#import "Constants.h"
#implementation DetailViewController
#synthesize CurrentLevel, CurrentTitle, tableDataSource,logoName,showDescription,showDescriptionInfo,showTime, showTimeInfo, tableBG;
- (void)layoutSubviews {
showLogo.frame = CGRectMake(40, 20, 187, 101);
showDescription.frame = CGRectMake(85, 140, 330, 65);
showTime.frame = CGRectMake(130, 10, 149, 119);
tableBG.frame = CGRectMake(0, 0, 480, 320);
}
/*
// The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
// Custom initialization
}
return self;
}
*/
/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationItem.title = CurrentTitle;
[showDescription setEditable:NO];
//show the description
showDescription.text = showDescriptionInfo;
showTime.text = showTimeInfo;
NSString *Path = [[NSBundle mainBundle] bundlePath];
NSString *ImagePath = [Path stringByAppendingPathComponent:logoName];
UIImage *tempImg = [[UIImage alloc] initWithContentsOfFile:ImagePath];
[showLogo setImage:tempImg];
[tempImg release];
[self masterView];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
isLandscape = UIInterfaceOrientationIsLandscape(toInterfaceOrientation);
if(isLandscape = YES){
[self layoutSubviews];
}
}
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[logoName release];
[showLogo release];
[showDescription release];
[showDescriptionInfo release];
[super dealloc];
}
#end
I believe that you need to pass the -shouldAutorotateToInterfaceOrientation: method to each view controller. You could do something like this in your UITabBarController:
- ( BOOL )shouldAutorotateToInterfaceOrientation:( UIInterfaceOrientation )
interfaceOrientation
{
for ( UIViewController *viewController in [ self viewControllers ])
[ viewController
shouldAutorotateToInterfaceOrientation:interfaceOrientation ];
return YES;
}