Я пытаюсь создать поповер со следующим кодом:UIPopoverController неприятности
//.h
@interface LoginViewController : UIViewController <UIPopoverControllerDelegate>
....
@end
//.m
- (IBAction)popoverTest:(id)sender
{
UIViewController *popoverContent = [[UIViewController alloc] init];
UIView *myView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 300)];
UILabel *nameLabel = [[UILabel alloc] init]; //edited, fixed UILabel allocation
nameLabel.text = @"Person's name";
[nameLabel sizeToFit];
nameLabel.frame = CGRectMake(10, 10, nameLabel.frame.size.width, nameLabel.frame.size.height);
[myView addSubview:nameLabel];
popoverContent.view = myView;
popoverContent.contentSizeForViewInPopover = CGSizeMake(300, 300);
UIPopoverController *popoverController = [[UIPopoverController alloc] initWithContentViewController:popoverContent];
popoverController.delegate = self;
[popoverController presentPopoverFromRect:((UIButton *)sender).frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
NSLog(@"ran all code");
}
Я создал UIView
, поставить метку как подвид, а затем присваивается свой вид на UIViewController.view
. Затем я создал контроллер popover, определил контроллер popover, установил делегат и представил его из фрейма кнопки.
Я получаю сообщение SIGABRT и приложение падает.
Есть ли что-то, что мне не хватает?
EDIT: Я установил распределение . Проблема всегда есть.
положить точку останова в вашем IBAction и посмотреть, где он сработает. включить также [исключения] (http://stackoverflow.com/questions/4961770/run-stop-on-objective-c-exception-in-xcode-4) –