我试图通过调用以下方法将一个推UIView
到另一个上:UIView
UINavigationController
signupPageObj = [[SignupPage alloc]initWithNibName:@"SignupPage" bundle:nil];
[self.navigationController pushViewController:signupPageObj animated:YES];
但是加载我的 SignUpPage 时卡住了一段时间UIView
。我不知道是什么原因,但因为我没有太多的自定义viewDidLoad
和方法initWithNibName
。
整个代码initWithNibName
如下:
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self)
{
statusArray=[[NSMutableArray alloc] init];
UILabel *labelforNavigationTitle = [[UILabel alloc] initWithFrame:CGRectZero];
labelforNavigationTitle.backgroundColor = [UIColor clearColor];
labelforNavigationTitle.font = [UIFont fontWithName:FONTSAVINGSBOND size:30.0];
labelforNavigationTitle.shadowColor = [UIColor colorWithWhite:0.0 alpha:0.5];
labelforNavigationTitle.textAlignment = UITextAlignmentCenter;
labelforNavigationTitle.textColor = [UIColor whiteColor]; // change this color
self.navigationItem.titleView = labelforNavigationTitle;
labelforNavigationTitle.text = NSLocalizedString(@"Sign Up", @"");
[labelforNavigationTitle sizeToFit];
}
return self;
}
-(void)viewDidLoad
{
[super viewDidLoad];
self.fullPathToFile=@"";
self.gender=@"";
strForGender=self.gender;
labelInDatePicker.font=[UIFont fontWithName:FONTCENTURYGOTHICBOLD size:17.0];
UIImage* imageCancel = [UIImage imageNamed:@"cancelbtn.png"];
CGRect frameimg = CGRectMake(0, 0, (imageCancel.size.width)/2, (imageCancel.size.height)/2);
UIButton *cancelButton = [[UIButton alloc] initWithFrame:frameimg];
[cancelButton setBackgroundImage:imageCancel forState:UIControlStateNormal];
[cancelButton addTarget:self action:@selector(cancelButtonclickedInAvtar)
forControlEvents:UIControlEventTouchUpInside];
[cancelButton setShowsTouchWhenHighlighted:YES];
self.pickerBirthdayView.frame=CGRectMake(0,460,320,252);
[self.view addSubview:self.pickerBirthdayView];
self.avtarView.frame=CGRectMake(0,460,320,460);
[self.view addSubview:self.avtarView];
cancelButtonInAvtarView=[[UIBarButtonItem alloc]initWithCustomView:cancelButton];
self.termsAndConditionPage.frame=CGRectMake(0,460,320,460);
[self.view addSubview:self.termsAndConditionPage];
if ([self.navigationController.navigationBar respondsToSelector:@selector(setBackgroundImage:forBarMetrics:)] )
{
UIImage *image = [UIImage imageNamed:@"titlebg.png"] ;
[self.navigationController.navigationBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
}
[self performSelector:@selector(settingScrollView) withObject:nil afterDelay:1.0];
scrollPrevButton.hidden=YES;
scrollNextButton.hidden=NO;
isSectionExpanded=NO;
checkForImage=2;
termsAndConditionChecked=2;
checkForBackgroundImage=10;
start=10;
UIImage* image1 = [UIImage imageNamed:@"backbtn.png"];
CGRect frameimg1 = CGRectMake(0, 0, (image1.size.width)/2, (image1.size.height)/2);
UIButton *backButton = [[UIButton alloc] initWithFrame:frameimg1];
[backButton setBackgroundImage:image1 forState:UIControlStateNormal];
[backButton addTarget:self action:@selector(popToRootViewController)
forControlEvents:UIControlEventTouchUpInside];
// UIImage* image2 = [UIImage imageNamed:@"submitbtn.png"];
// CGRect frameimg2 = CGRectMake(0, 0, (image2.size.width)/2, (image2.size.height)/2);
// UIButton *submitButton = [[UIButton alloc] initWithFrame:frameimg2];
// [submitButton setBackgroundImage:image2 forState:UIControlStateNormal];
// [submitButton addTarget:self action:@selector(submitButtonPressed:)forControlEvents:UIControlEventTouchUpInside];
UIImage* imageforTermsandConditionPage = [UIImage imageNamed:@"backbtn.png"];
CGRect frameimgforTermsandConditionPage = CGRectMake(0, 0, (imageforTermsandConditionPage.size.width)/2, (imageforTermsandConditionPage.size.height)/2);
UIButton *backButtonforTermsandConditionPage = [[UIButton alloc] initWithFrame:frameimgforTermsandConditionPage];
[backButtonforTermsandConditionPage setBackgroundImage:imageforTermsandConditionPage forState:UIControlStateNormal];
[backButtonforTermsandConditionPage addTarget:self action:@selector(backtoSignupPage) forControlEvents:UIControlEventTouchUpInside];
UIImage* imageforChooseIconPage = [UIImage imageNamed:@"backbtn.png"];
CGRect frameimgforChooseIconPage = CGRectMake(0, 0, (imageforChooseIconPage.size.width)/2, (imageforChooseIconPage.size.height)/2);
UIButton *backButtonforChooseIconPage = [[UIButton alloc] initWithFrame:frameimgforChooseIconPage];
[backButtonforChooseIconPage setBackgroundImage:imageforTermsandConditionPage forState:UIControlStateNormal];
[backButtonforChooseIconPage addTarget:self action:@selector(backtoSignupPage) forControlEvents:UIControlEventTouchUpInside];
backButton1 = [[UIBarButtonItem alloc] initWithCustomView:backButton];
self.navigationItem.leftBarButtonItem = backButton1;
// submitButton1=[[UIBarButtonItem alloc]initWithCustomView:submitButton];
// self.navigationItem.rightBarButtonItem=submitButton1;
backButtonInTermsAndCondition=[[UIBarButtonItem alloc]initWithCustomView:backButtonforTermsandConditionPage];
backButtonInChooseIcon=[[UIBarButtonItem alloc]initWithCustomView:backButtonforChooseIconPage];
CALayer *layer = [self.objTextView layer];
[layer setMasksToBounds:YES];
[layer setCornerRadius:10.0];
[layer setBorderWidth:0.0];
[layer setBorderColor:[[UIColor lightGrayColor] CGColor]];
}
-(void)settingScrollView
{
arrOfImages=[NSArray arrayWithObjects:@"Avtar0.png",@"Avtar1.png",@"Avtar2.png",@"Avtar3.png",@"Avtar4.png",@"Avtar5.png",@"Avtar6.png",@"Avtar7.png",@"Avtar8.png",@"Avtar9.png",nil];
pageControl.numberOfPages = kNumberOfPages;
pageControl.currentPage = 0;
pageControl = [[PageControl alloc] initWithFrame:rect] ;
pageControl.frame = rect;
pageControl.delegate=self;
pageControl.numberOfPages=[arrOfImages count];
pageControl.currentPage = self.currentPage;
[self.view addSubview:pageControl];
scrollV = [[UIScrollView alloc]init];
scrollV.frame=CGRectMake(35,55,250,246);
scrollV.backgroundColor=[UIColor clearColor];
scrollV.delegate=self;
scrollV.pagingEnabled=YES;
self.scrollV.contentSize = CGSizeMake(self.scrollV.frame.size.width *kNumberOfPages, 220);
self.scrollV.showsHorizontalScrollIndicator = NO;
self.scrollV.showsVerticalScrollIndicator = NO;
self.scrollV.scrollsToTop = NO;
self.scrollV.delegate = self;
[self.avtarView addSubview:scrollV];
for(int k =0;k<arrOfImages.count;k++)
{
UIButton *btn=[UIButton buttonWithType:UIButtonTypeCustom];
btn.tag=k;
btn.imageView.contentMode= UIViewContentModeScaleAspectFit;
[btn setImage:[UIImage imageNamed:[arrOfImages objectAtIndex:k]] forState:UIControlStateNormal];
[btn setImage:[UIImage imageNamed:[arrOfImages objectAtIndex:k]] forState:UIControlStateHighlighted];
btn.frame=CGRectMake((self.scrollV.frame.size.width * k),0, 250,241);
[btn addTarget:self action:@selector(setImageInScrollView:) forControlEvents:UIControlEventTouchUpInside];
[self.scrollV addSubview:btn];
}
}
如果有人对此有建议或解决方案,我将不胜感激。