Skip to content

Instantly share code, notes, and snippets.

@patelrohan
Created March 9, 2012 09:08
Show Gist options
  • Save patelrohan/2005774 to your computer and use it in GitHub Desktop.
Save patelrohan/2005774 to your computer and use it in GitHub Desktop.
Scrollsetup
-(void)setUpMiniOnOrientation
{
//RECUPERATION DES PROJETS
if (projectArray != nil)
{
projectArray = nil;
[projectArray release];
}
if (managedObjectContext == nil)
{
managedObjectContext = [(AppDelegate *)[[UIApplication sharedApplication] delegate] managedObjectContext];
NSLog(@"After managedObjectContext: %@", managedObjectContext);
}
// NSLog(@"sadfsdf %@",managedObjectContext);
[managedObjectContext userInfo];
//-----------------------------------Fetch Request---------------------------------------
NSError *error;
NSFetchRequest *fetchRequest1 = [[NSFetchRequest alloc] init];
NSEntityDescription *entity1 = [NSEntityDescription
entityForName:@"Project" inManagedObjectContext:managedObjectContext];
[fetchRequest1 setEntity:entity1];
NSMutableArray *mutableFetchResults = [[managedObjectContext executeFetchRequest:fetchRequest1 error:&error]mutableCopy];
// [self setEventsArray:mutableFetchResults];
projectArray=[[NSMutableArray alloc]initWithArray:mutableFetchResults];
NSLog(@"%d",[projectArray count]);
//Project *project = (Project *)[eventsArray objectAtIndex:0];
[fetchRequest1 release];
int scrollLen=0;
for (int i=0; i<[projectArray count]; i++)
{
int xPos=10;
//int yPos=350;
scrollLen= i*400+(i+1)*xPos;
NSLog(@"%d",scrollLen);
UIView *topView = [[UIView alloc] initWithFrame:CGRectMake(i*400+(i+1)*xPos,20, 400,400)];
topView.backgroundColor=[UIColor grayColor];
Project *currentProject = (Project *)[projectArray objectAtIndex:i];
NSLog(@"Name: %@ \n Date: %@",currentProject.name,currentProject.created);
UILabel *lblProjName=[[UILabel alloc]init];
lblProjName.frame=CGRectMake(5,5,110,21);
[lblProjName setTextAlignment:UITextAlignmentLeft];
lblProjName.text=@" Project name";
lblProjName.font = [UIFont fontWithName:@"Helvetica" size:14.0];
lblProjName.backgroundColor=[UIColor whiteColor];
[topView addSubview:lblProjName];
[lblProjName release];
UILabel *lblCreated=[[UILabel alloc]init];
lblCreated.frame=CGRectMake(120,5,150,21);
[lblCreated setTextAlignment:UITextAlignmentCenter];
lblCreated.text=currentProject.name;
lblCreated.font = [UIFont fontWithName:@"Helvetica" size:14.0];
lblCreated.backgroundColor=[UIColor whiteColor];
[topView addSubview:lblCreated];
[lblCreated release];
UILabel *lblCreated1=[[UILabel alloc]init];
lblCreated1.frame=CGRectMake(5,30,110,21);
[lblCreated1 setTextAlignment:UITextAlignmentLeft];
lblCreated1.text=@" Date created";
lblCreated1.font = [UIFont fontWithName:@"Helvetica" size:14.0];
lblCreated1.backgroundColor=[UIColor whiteColor];
[topView addSubview:lblCreated1];
[lblCreated1 release];
UILabel *lblProjName1=[[UILabel alloc]init];
lblProjName1.frame=CGRectMake(120,30,150,21);
[lblProjName1 setTextAlignment:UITextAlignmentCenter];
lblProjName1.text=@"9/5/90";
lblProjName1.font = [UIFont fontWithName:@"Helvetica" size:14.0];
lblProjName1.backgroundColor=[UIColor whiteColor];
[topView addSubview:lblProjName1];
[lblProjName1 release];
/*
CGRect frame=CGRectMake(120,80, 165, 120);//+220);
UIImage *img= [UIImage imageNamed:@"iconMini.png"];
UIImageView *imgView= [[UIImageView alloc]initWithImage:img];
imgView.frame=frame;
[topView addSubview:imgView];
//async.backgroundColor=[UIColor whiteColor];
[imgView release];
*/
UIButton *btnEdit=[UIButton buttonWithType:UIButtonTypeRoundedRect];
[btnEdit setTitle:@"Edit" forState:UIControlStateNormal];
[btnEdit addTarget:self action:@selector(editProject:) forControlEvents:UIControlEventTouchUpInside];
btnEdit.frame=CGRectMake(285, 126, 72, 25);
[topView addSubview:btnEdit];
//[btnEdit release];
UILabel *lblNoOfBuildings=[[UILabel alloc]init];
lblNoOfBuildings.frame=CGRectMake(5,230, 110,21);
[lblNoOfBuildings setTextAlignment:UITextAlignmentLeft];
lblNoOfBuildings.text=@"No Of Buildings";
lblNoOfBuildings.font = [UIFont fontWithName:@"Helvetica" size:14.0];
lblNoOfBuildings.backgroundColor=[UIColor whiteColor];
[topView addSubview:lblNoOfBuildings];
[lblNoOfBuildings release];
UILabel *lblNoOfBuildings1=[[UILabel alloc]init];
lblNoOfBuildings1.frame=CGRectMake(120,230, 30,21);
[lblNoOfBuildings1 setTextAlignment:UITextAlignmentCenter];
lblNoOfBuildings1.text=@"10";
lblNoOfBuildings1.font = [UIFont fontWithName:@"Helvetica" size:14.0];
lblNoOfBuildings1.backgroundColor=[UIColor whiteColor];
[topView addSubview:lblNoOfBuildings1];
[lblNoOfBuildings1 release];
UILabel *lblNoOfWorkers=[[UILabel alloc]init];
lblNoOfWorkers.frame=CGRectMake(5,260, 110,21);
[lblNoOfWorkers setTextAlignment:UITextAlignmentLeft];
lblNoOfWorkers.text=@"No Of Workers";
lblNoOfWorkers.font = [UIFont fontWithName:@"Helvetica" size:14.0];
lblNoOfWorkers.backgroundColor=[UIColor whiteColor];
[topView addSubview:lblNoOfWorkers];
[lblNoOfWorkers release];
UILabel *lblNoOfWorkers1=[[UILabel alloc]init];
lblNoOfWorkers1.frame=CGRectMake(120,260, 30,21);
[lblNoOfWorkers1 setTextAlignment:UITextAlignmentCenter];
lblNoOfWorkers1.text=@"5";
lblNoOfWorkers1.font = [UIFont fontWithName:@"Helvetica" size:14.0];
lblNoOfWorkers1.backgroundColor=[UIColor whiteColor];
[topView addSubview:lblNoOfWorkers1];
[lblNoOfWorkers1 release];
UILabel *lblReserves=[[UILabel alloc]init];
lblReserves.frame=CGRectMake(5,290, 110,21);
[lblReserves setTextAlignment:UITextAlignmentLeft];
lblReserves.text=@"Reserves";
lblReserves.font = [UIFont fontWithName:@"Helvetica" size:14.0];
lblReserves.backgroundColor=[UIColor whiteColor];
[topView addSubview:lblReserves];
[lblReserves release];
UILabel *lblReserves1=[[UILabel alloc]init];
lblReserves1.frame=CGRectMake(120,290, 50,21);
[lblReserves1 setTextAlignment:UITextAlignmentCenter];
lblReserves1.text=@"Res";
lblReserves1.font = [UIFont fontWithName:@"Helvetica" size:14.0];
lblReserves1.backgroundColor=[UIColor whiteColor];
[topView addSubview:lblReserves1];
[lblReserves1 release];
UILabel *lblCompletion=[[UILabel alloc]init];
lblCompletion.frame=CGRectMake(220,230, 110,21);
[lblCompletion setTextAlignment:UITextAlignmentLeft];
lblCompletion.text=@"Completed";
lblCompletion.font = [UIFont fontWithName:@"Helvetica" size:14.0];
lblCompletion.backgroundColor=[UIColor whiteColor];
[topView addSubview:lblCompletion];
[lblCompletion release];
UILabel *lblCompletion1=[[UILabel alloc]init];
lblCompletion1.frame=CGRectMake(350,230,50,21);
[lblCompletion1 setTextAlignment:UITextAlignmentCenter];
lblCompletion1.text=@"60%";
lblCompletion1.font = [UIFont fontWithName:@"Helvetica" size:14.0];
lblCompletion1.backgroundColor=[UIColor whiteColor];
[topView addSubview:lblCompletion1];
[lblCompletion1 release];
UILabel *lblNoOfPlans=[[UILabel alloc]init];
lblNoOfPlans.frame=CGRectMake(220,260, 110,21);
[lblNoOfPlans setTextAlignment:UITextAlignmentLeft];
lblNoOfPlans.text=@"No Of Plans";
lblNoOfPlans.font = [UIFont fontWithName:@"Helvetica" size:14.0];
lblNoOfPlans.backgroundColor=[UIColor whiteColor];
[topView addSubview:lblNoOfPlans];
[lblNoOfPlans release];
UILabel *lblNoOfPlans1=[[UILabel alloc]init];
lblNoOfPlans1.frame=CGRectMake(350,260, 50,21);
[lblNoOfPlans1 setTextAlignment:UITextAlignmentCenter];
lblNoOfPlans1.text=@"15";
lblNoOfPlans1.font = [UIFont fontWithName:@"Helvetica" size:14.0];
lblNoOfPlans1.backgroundColor=[UIColor whiteColor];
[topView addSubview:lblNoOfPlans1];
[lblNoOfPlans1 release];
UILabel *lblCity=[[UILabel alloc]init];
lblCity.frame=CGRectMake(220,290, 110,21);
[lblCity setTextAlignment:UITextAlignmentLeft];
lblCity.text=@"City";
lblCity.font = [UIFont fontWithName:@"Helvetica" size:14.0];
lblCity.backgroundColor=[UIColor whiteColor];
[topView addSubview:lblCity];
[lblCity release];
UILabel *lblCity1=[[UILabel alloc]init];
lblCity1.frame=CGRectMake(350,290, 50,21);
[lblCity1 setTextAlignment:UITextAlignmentCenter];
lblCity1.text=@"SF, L.A.";
lblCity1.font = [UIFont fontWithName:@"Helvetica" size:14.0];
lblCity1.backgroundColor=[UIColor whiteColor];
[topView addSubview:lblCity1];
[lblCity1 release];
[projectScroll addSubview:topView];
[topView release];
}
projectScroll.contentSize = CGSizeMake(scrollLen+400,450);
NSLog(@"%d",scrollLen);
NSLog(@"%d",[projectArray count]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment