Загрузить вид на UIButton Click - PullRequest
0 голосов
/ 22 июля 2011

Я пытаюсь установить UIViewController на UIB, нажав

.

GehaltVIew.m

#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 Семинар App2 [33791: 207] - [Berechnen setFrame:]: нераспознанный селектор отправлен в экземпляр 0x5d05bd0

1 Ответ

2 голосов
/ 22 июля 2011

Из этого утверждения:

 Berechnen *dvController = [[Berechnen alloc] initWithNibName:@"Berechnen" bundle:nil];

мне кажется, Berechnen должно быть UIViewController, а не UIView, поэтому следующая строка должна быть:

self.view = dvController.view;

Пожалуйста, обратите внимание, что в tableView:viewForFooterInSection вы, возможно, протекаете footerView. Я думаю, что вы должны автоматически выпустить footerView:

UIView *footerView  = [[[UIView alloc] init] autorelease];
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...