我正在以其他方法添加子视图,viewDidLoad()
并且不显示子视图。我的代码在下面:
-(void) displayBanner
{
SharedApp *instance=[SharedApp sharedInstance];
[NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(targetMethod:) userInfo:nil repeats:YES];
numTimerTicks = 0;
roundedButtonType = [[UIButton buttonWithType:UIButtonTypeRoundedRect]retain]; //Creates a UIButton
roundedButtonType.frame = CGRectMake(0.0f, 360.0f, 320.0f, 60.0f); //sets the coordinates and dimensions of UIButton
roundedButtonType.backgroundColor = [UIColor clearColor]; //sets the background color
roundedButtonType.tag = numTimerTicks;
// [instance configView];
NSLog(@"the home array is %@",instance.homeImageArray);
[roundedButtonType setBackgroundImage:[instance.homeImageArray objectAtIndex:numTimerTicks] forState:UIControlStateNormal];
[roundedButtonType addTarget:self action:@selector(showDetails:)forControlEvents:UIControlEventTouchUpInside]; //sets the Background image
[roundedButtonType setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
HomePageViewController *homepage = [[HomePageViewController alloc]initWithNibName:@"HomePageViewController" bundle:nil];
[homepage.view addSubview:roundedButtonType];
//Oops forgot to add this one... my bad.. :D :D
[self.view addSubview:homepage.view];// Image displayed but goes into endless loop
}
谁能让我知道我是否做得对以及我错过了什么?
提前致谢。