hi iProgrammers,
i have 5 tabs,namely home,ask a doc,tip,inbox and disclaimer....im my home view controller i zoom an image in viewforzoominginscrollview method...after zooming if i switch to another tab and then get back to home tab....i want the image to be of actual size...
This is my homeViewController class code
import "HomeViewController.h"
import "DisclaimerViewController.h"
import "DetailsViewController.h"
import "AskADocViewController.h"
import "iDocAppDelegate.h"
import "iDocViewController.h"
@implementation HomeViewController @synthesize scroll; @synthesize bodypartdetails; @synthesize array; @synthesize aPicker; //@synthesize aSelectedValue; static NSString* aSelectedValue; BOOL changeTabindex; UIBarButtonItem *Done; UIBarButtonItem *Cancel; //@synthesize Done; //@synthesize Cancel;
// 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 } self.title = @"Home"; return self; }
-(IBAction)RemoveTable:(id)sender { if(aTableView.hidden==NO) { [aTableView setHidden:YES]; }
//[aTableView removeFromSuperview];
} - (void)viewWillAppear:(BOOL)animated { [self.view bringSubviewToFront:aButton]; if(aAskaDoc) { [aAskaDoc.view removeFromSuperview]; } //[self.view insertSubview:aButton atIndex:1]; //[self.tabBarController setSelectedIndex:0]; //[aImageView setFrame:CGRectMake(0, 10, 320, 400)]; //NSLog(@"%f, %f",aImageView.frame.size.width, aImageView.frame.size.height );
//[scroll setContentSize:CGSizeMake(320,480)];
}
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib. - (void)viewDidLoad { // [self.tabBarController setSelectedIndex:0];
[scroll setFrame:CGRectMake(0, 0, 320, 415)];
[aTableView setHidden:YES];
[aTableView setBackgroundColor:[UIColor clearColor]];
self.navigationController.navigationBarHidden = YES;
/* [aDisplayView setFrame:CGRectMake(0, 0, 320, 415)]; [aImageView setFrame:CGRectMake(0, 0, 320, 415)];
[aButtonImage setFrame:CGRectMake(0, 0, 320, 415)];
[aDisplayView addSubview:aImageView];
//[aPicker setFrame:CGRectMake(1, 460, 320, 216)];
// aPicker.delegate=self; */ [scroll setCanCancelContentTouches:NO]; [aButtonImage setFrame:CGRectMake(0, 20, 320, 415)];
scroll.clipsToBounds = YES; // default is NO, we want to restrict drawing within our scrollview
scroll.indicatorStyle = UIScrollViewIndicatorStyleBlack;
scroll.showsVerticalScrollIndicator=YES;
aImageView.userInteractionEnabled = YES;
[scroll setMaximumZoomScale: 2.0f];
[scroll setMinimumZoomScale: 1.0f];
[scroll setDelegate:self];
//[scroll setPagingEnabled:YES];
// [aImageView setFrame:CGRectMake(0, 0, 320, 400)];
// [aDisplayView addSubview:aPicker]; // [aDisplayView addSubview:bar];
//[aDisplayView addSubview:flashScrollIndicators];
[scroll addSubview:aDisplayView];
[scroll flashScrollIndicators];
//[scroll addSubview:bar];
[scroll setScrollEnabled:YES];
scroll.userInteractionEnabled=YES;
// NSLog(@"%d, %d, %d, %d ",aImageView.frame.origin.x, aImageView.frame.origin.y, aImageView.frame.size.width, aImageView.frame.size.height ); [scroll setContentSize:CGSizeMake(320,410)];
[super viewDidLoad];
}
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView { //[imageView removeFromSuperview]; //[aDisplayView setFrame:CGRectMake(1, 10, 800, 780)]; //self.view=scrollView; return aDisplayView; } -(IBAction) MediclaSpecilisation:(id)sender {
// firstViewController = [[FirstViewController alloc] init]; // secondViewController = [[SecondViewController alloc] init]; aSpecViewController=[[SelectSpecViewController alloc]initWithNibName:@"SelectSpecViewController" bundle:nil]; [self.view addSubview:aSpecViewController.view]; //[self.navigationController pushViewController:aSpecViewController animated:YES]; // [aSpecViewController release]; //Make the first View be INSIDE the normal window's bounds // firstViewController.view.frame = CGRectMake(0,0,320,480);
//And the to-come-view to be on the right site, therefore 321
// aSpecViewController.view.frame = CGRectMake(0,321,320,480);
// [UIView beginAnimations:nil context:NULL];
// [UIView setAnimationDuration:1.0];
// [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:NO];
//
// [self.view addSubview:aSpecViewController.view];
// [UIView commitAnimations];
} -(IBAction)AskADoc:(id)sender {
//changeTabindex=YES;
// //[self.tabBarController setSelectedIndex:1];
//
//// [self.tabBarController setSelectedIndex:1];
//if(aAskaDoc)
//[aAskaDoc release];
//aAskaDoc=[[AskADocViewController alloc] initWithNibName:@"AskADocViewController" bundle:nil];
//// UIView currview = self.view;
//
//[UIView beginAnimations:nil context:NULL];
//[UIView setAnimationDuration:1.0];
//
// // Tell the main view (blue) to curl up. Cache is for future performance.
// //
//[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:NO];
//[aHomeCont.view removeFromSuperview]; // remove the optionInterface that is loaded
//// iDocAppDelegate theDelegate = (iDocAppDelegate*)[[UIApplication sharedApplication] delegate];
//// tabbarController = theDelegate.tabbarController;
//// tabbarController.selectedIndex = 1;
//
//[self.view addSubview:aAskaDoc.view]; // add the numberInterface
//[UIView commitAnimations];
//
//// iDocAppDelegate appDel = (iDocAppDelegate)[[UIApplication sharedApplication]delegate];
//// appDel.viewController.tabbarController.selectedIndex = 1;
//
// //iDocViewController* aViewcon=[[iDocViewController alloc]init];
//
// //[aViewcon createTabBar];
//
// //[self.tabBarController setSelectedIndex:1];
//
//
// //[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:NO];
// //[self.view addSubview:aAskaDoc.view];
//
// //[UIView commitAnimations];
//// [aAskaDoc release];
// //[self.tabBarController setSelectedIndex:1];
// //[currview removeFromSuperview];
//// [currview release];
// // UIView *nextView = nextViewID.view;
//
//iDocAppDelegate *appDel = (iDocAppDelegate*)[[UIApplication sharedApplication]delegate];
//appDel.viewController.tabbarController.selectedIndex = 1;
}
/* - (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(float)scale { [scroll setContentSize:CGSizeMake(aDisplayView.frame.size.width,aDisplayView.frame.size.height)]; } / / - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch=[[event allTouches]anyObject]; location1=[touch locationInView:touch.view]; NSLog(@"%f",location1.x); }
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch=[[event allTouches]anyObject]; location2=[touch locationInView:touch.view]; if(location2.xlocation1.y-location2.y)) {} //[nav pushViewController:svc animated:YES];
} */
-(IBAction) BrainButtonClick:(id)sender {
if(array)
{
[array release];
array=nil;
}
[aTableView setFrame:CGRectMake(80, 95, 250, 125)];
array=[[NSMutableArray alloc]init];
[array addObject:@"Neurology"];
[array addObject:@"Neurosurgery"];
[array addObject:@"Psychologist"];
[array addObject:@"Psychiatry"];
[aTableView reloadData];
[aTableView setHidden:NO];
}
-(IBAction) BonesButtonClick:(id)sender
{
if(array)
{
[array release];
array=nil;
}
array=[[NSMutableArray alloc]init];
[array addObject:@"Orthopaedic Surgery"];
[aTableView reloadData];
[aTableView setFrame:CGRectMake(80, 170, 250, 40)];
[aTableView setHidden:NO];
}
-(IBAction) ReproductiveButtonClick:(id)sender {
if(array)
{
[array release];
array=nil;
}
array=[[NSMutableArray alloc]init];
[array addObject:@"Urology"];
[array addObject:@"Obstetrics and Gynaecology"];
[aTableView reloadData];
[aTableView setFrame:CGRectMake(80, 150, 250, 60)];
[aTableView setHidden:NO];
} -(IBAction) EyesButtonClick:(id)sender {
if(array)
{
[array release];
array=nil;
}
array=[[NSMutableArray alloc]init];
[array addObject:@"Ophthalmology"];
[aTableView reloadData];
[aTableView setFrame:CGRectMake(80, 100, 250, 40)];
[aTableView setHidden:NO];
}
-(IBAction) NoseButtonClick:(id)sender {
if(array)
{
[array release];
array=nil;
}
array=[[NSMutableArray alloc]init];
[array addObject:@"Otolaryngology"];
[aTableView reloadData];
[aTableView setFrame:CGRectMake(80, 120, 250, 40)];
[aTableView setHidden:NO];
}
-(IBAction) ChestButtonClick:(id)sender
{
if(array)
{
[array release];
array=nil;
}
array=[[NSMutableArray alloc]init];
[array addObject:@"Emergency Medicine"];
[array addObject:@"Family Medicine"];
[array addObject:@"General surgery"];
[array addObject:@"Pediatrician"];
[array addObject:@"Radiation Oncology"];
[array addObject:@"Internal medicine"];
[aTableView reloadData];
[aTableView setFrame:CGRectMake(80, 150, 250, 180)];
[aTableView setHidden:NO];
}
-(IBAction) EarButtonClick:(id)sender {
if(array)
{
[array release];
array=nil;
}
array=[[NSMutableArray alloc]init];
[array addObject:@"Otolaryngology"];
[aTableView reloadData];
[aTableView setFrame:CGRectMake(20, 150, 250, 40)];
[aTableView setHidden:NO];
}
-(IBAction) SkinButtonClick:(id)sender {
if(array)
{
[array release];
array=nil;
}
array=[[NSMutableArray alloc]init];
[array addObject:@"Dermatology"];
[aTableView reloadData];
[aTableView setFrame:CGRectMake(20, 250, 250,40)];
[aTableView setHidden:NO];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; }
(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { //globalArray=[aCat allKeys];
static NSString *CellIdentifier = @"Cell";UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell != nil) { cell=nil; }
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
UILabel* alabel=[[UILabel alloc]initWithFrame:CGRectMake(1, 1, 210, 30)]; [alabel setBackgroundColor:[UIColor clearColor]]; alabel.text=[array objectAtIndex:indexPath.row]; alabel.textAlignment=UITextAlignmentRight; [alabel setFont:[UIFont fontWithName:@"Arial" size:16]]; UIImageView* aGreenImageView=[[UIImageView alloc]initWithFrame:CGRectMake(211, 1, 30, 30)]; [aGreenImageView setImage:[UIImage imageNamed:@"but_arrow.png"]];
// UIButton* aButton=[[UIButton alloc]initWithFrame:CGRectMake(211, 1, 30, 30)]; // [aButton setBackgroundImage:[UIImage imageNamed:@"but_arrow.png"] forState:UIControlStateNormal];
[cell.contentView addSubview:alabel];
[cell.contentView addSubview:aGreenImageView];
// [cell.contentView addSubview:aButton]; return cell; }
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { if([array count]==0) return 2; else return [array count]; // return [globalArray count]; //return 0; }
(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; // Disney_database *db = (Disney_database *)[appDelegate.categories objectAtIndex:indexPath.row]; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease]; } [aTableView setHidden:YES]; aSelectedValue=[array objectAtIndex:indexPath.row]; aDetailController=[[DetailsViewController alloc]initWithNibName:@"DetailsViewController" bundle:nil]; [UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:NO];
[aDetailController showDetails:aSelectedValue]; [self.view addSubview:aDetailController.view];[UIView commitAnimations];
}
(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 { [aHomeCont release]; [super dealloc]; }
@end