добавить кнопку программен с помощью внешнего класса:добавление кнопки программно
файла заголовок: метод
-(UIView*) makeButtonNotification;
файла:
-(UIView*) makeButtonNotification{
UIImage * buttonImage = [UIImage imageNamed:@"chat-notify.png"];
button = [UIButton buttonWithType:UIButtonTypeCustom];
[button addTarget:self
action:@selector(goChat)
forControlEvents:UIControlEventTouchUpInside];
button.frame = CGRectMake(280.0, 25.0, 30.0, 30.0);
[button setBackgroundImage:buttonImage forState:UIControlStateNormal];
return button;
}
этой кнопка вызова goChat метод
- (void)goChat{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
chat = (chatViewController *)[storyboard instantiateViewControllerWithIdentifier:@"chatViewController"];
chat.view.layer.zPosition = 10;
[[[[UIApplication sharedApplication] delegate] window] setRootViewController:chat];
}
я добавить вид с этим кодом:
[[[[UIApplication sharedApplication] delegate] window] setRootViewController:chat];
потому Otherways у меня есть проблемы с иерархией
чей вид не в иерархии окон!
я называю метод, как это:
notificationViewController* notification = [[notificationViewController alloc]init];
[self.view addSubview:[notification makeButtonNotification]];
теперь вид появляются, и это не проблема.
, но при появлении у меня есть кнопка с раскадрой для открытого меню левой панели, и это не работает.
есть какое-то другое решение?
спасибо.