嘿我自动将我的项目转换为ARC,我唯一需要解决的是Xcode更改了大小为[8]到[4]的数组(仍然不知道那里发生了什么)
然而,我现在意识到我遇到了另一个问题:每当我点击弹出窗口中的按钮时,如果应用程序链接到IBAction,应用程序就会崩溃。如果我删除对标题和主文件的引用,则该按钮是可单击的,但是只要我将其分配给方法(即使该方法为空),整个应用程序jut会冻结/崩溃。
这是我启动弹出窗口的方式:
PopUpViewController *popViewController =
[[PopUpViewController alloc] initWithNibName:@"PopUpViewController" bundle:nil];
[popViewController setTitle:@"This is a popup view"];
[popViewController showInView:self.view
animated:YES];
popViewController.view.center=self.view.center;
非常基本的东西,我把它从我在网上发现的教程中删除了。我的标题是:
@interface PopUpViewController : UIViewController
- (IBAction)baa:(id)sender;
@property (strong, nonatomic) UIButton *ba; // I was trying to add those buttons as properties here
@property (strong, nonatomic) IBOutlet UIButton *kl; //but no luck whatsoever
@property (strong, nonatomic) IBOutlet UIView *popUpView;
@property (strong, nonatomic) IBOutlet UIView *ppp;
- (IBAction)openSomething:(id)sender;
- (IBAction)openYoutube:(id)sender;
- (IBAction)openFacebook:(id)sender;
- (void)showInView:(UIView *)aView animated:(BOOL)animated;
@end
我的主要
#import "PopUpViewController.h"
@interface PopUpViewController ()
@end
@implementation PopUpViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
}
return self;
}
- (void)showAnimate
{
// not important for this question
}
- (void)removeAnimate
{
// shortened
}
- (IBAction)baa:(id)sender{
// NSLog(@"asd"); I commented it out, but even an empty method kills the app
// only if I leave a button unassigned to any method, the app "survives" a button click
}
- (IBAction)openSomething:(id)sender
{
// [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.test.de"]];
}
- (IBAction)openYoutube:(id)sender
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://www.youtube.com/"]];
}
- (IBAction)openFacebook:(id)sender
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"https://www.facebook.com/"]];
}
- (void) doSomething{
// also tried an empty method with a "new" name over here to eliminate any caching errors, no luck
}
- (IBAction)closePopup:(id)sender {
[self removeAnimate];
}
- (void)showInView:(UIView *)aView animated:(BOOL)animated
{
[aView addSubview:self.view];
if (animated) {
[self showAnimate];
}
}
- (void)viewDidLoad
{
self.view.backgroundColor=[[UIColor blackColor] colorWithAlphaComponent:.0];
self.popUpView.layer.cornerRadius = 5;
self.popUpView.layer.shadowOpacity = 1.0;
self.popUpView.layer.shadowOffset = CGSizeMake(0.2f, 0.2f);
[super viewDidLoad];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
@end
我能做些什么不同的想法?我现在把所有内容都引用到其他所有内容上,我甚至不知道它之前的样子,但我不知道它是否与引用有关。
非常感谢,Alex
答案 0 :(得分:0)
我能够自己搞清楚:
在我的主ViewController的标题中,我添加了
@property (strong, nonatomic) PopUpViewController *popViewController;
仍然引发了崩溃。但后来我将弹出的“开放”块调整为
_popViewController =
[[PopUpViewController alloc] initWithNibName:@"PopUpViewController" bundle:nil];
[_popViewController setTitle:@"This is a popup view"];
[_popViewController showInView:self.view
animated:YES];
_popViewController.view.center=self.view.center;
(添加了下划线),现在它再次完美运作。
实际上我很好奇为什么它之前有用,但我不打算进一步调查这个。