我正在制作一个应用程序,其中我在childView上添加了四个类
[self addChildViewController:homeScreenViewController];
[self addChildViewController:portFolioViewController];
[self addChildViewController:watchListViewController];
[self addChildViewController:marketingViewController];
我将pageControl上的childView称为分页。 现在在homeScreenViewController类上我添加了一个按钮,但按钮不采取任何操作。
我在HomeScreenViewController类中声明了这样的按钮。这是代码
btn_Trade = [UIButton buttonWithType:UIButtonTypeCustom];
btn_Trade.frame = CGRectMake(0.0, 150.0, 142.0, 40.0);
[btn_Trade setTitle:@"TRADE" forState:UIControlStateNormal];
[btn_Trade setBackgroundColor:[UIColor redColor]];
btn_Trade.titleLabel.font = [UIFont fontWithName:@"SegoeUI-Light" size:20.0];
[btn_Trade setContentHorizontalAlignment:UIControlContentHorizontalAlignmentCenter];
[btn_Trade setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[btn_Trade addTarget:self action:@selector(pushToTradeListViewController) forControlEvents:UIControlEventTouchUpInside];
[btn_Trade setEnabled:YES];
[self.view addSubview:btn_Trade];
请建议我。
答案 0 :(得分:0)
你可以添加pushToTradeListViewController方法的代码吗?
BTW,如果你的pushToTradeListViewController看起来像那样:
-(void)pushToTradeListViewController:(id)sender{
....
}
您需要在选择器中添加:
(2分)方法名称,如下所示:
[btn_Trade addTarget:self action:@selector(pushToTradeListViewController:) forControlEvents:UIControlEventTouchUpInside];