Objective c 单击“加载视图”按钮
我尝试在UIViewController上单击UIButton GehaltVIew.mObjective c 单击“加载视图”按钮,objective-c,xcode,Objective C,Xcode,我尝试在UIViewController上单击UIButton GehaltVIew.m #import "GehaltVIew.h" #import "Berechnen.h" - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section { UIView *footerView = [[UIView alloc] init]; UIButton *ber
#import "GehaltVIew.h"
#import "Berechnen.h"
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
UIView *footerView = [[UIView alloc] init];
UIButton *berechnenButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
berechnenButton.frame = CGRectMake(10, 10, 300, 40);
[berechnenButton setTitle:@"Berechnen!" forState:UIControlStateNormal];
[berechnenButton addTarget:self action:@selector(berechnenGehalt) forControlEvents:UIControlEventTouchUpInside];
[footerView addSubview:berechnenButton];
return footerView;
}
- (void)berechnenGehalt
{
Berechnen *dvController = [[Berechnen alloc] initWithNibName:@"Berechnen" bundle:nil];
self.view = dvController;
}
但我得到了这个错误:
2011-07-22 14:51:59.598研讨会附录2[33791:207]-[Berechnen setFrame:]:从该语句发送到实例0x5d05bd0的未识别选择器:
Berechnen *dvController = [[Berechnen alloc] initWithNibName:@"Berechnen" bundle:nil];
在我看来,Berechnen
应该是UIViewController
,而不是UIView
,因此下一行应该是:
self.view = dvController.view;
请注意,在tableView:viewforfooterInstitution
中,您可能正在泄漏footerView
。我认为您应该自动释放页脚视图:
UIView *footerView = [[[UIView alloc] init] autorelease];