2015-03-31 64 views
0

嘿,我自動將我的項目轉換爲ARC,唯一需要修復的是Xcode更改了數組大小爲[8]至[4](仍然不知道是什麼在那裏)iOS Popup在轉換爲ARC後被破壞

但是,我現在意識到我有另一個問題:每當我彈出一個按鈕在我的Popup,應用程序崩潰,如果它連接到一個IBAction。如果我刪除對頭文件和主文件的引用,該按鈕是可點擊的,但只要我將它分配給方法(即使該方法爲空),整個應用程序就會凍結/崩潰。

這是我開始我的彈出:

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 

任何想法我能做什麼不同?我現在引用了其他所有可能的東西,我甚至不知道它以前的樣子,但我總覺得它與引用有關。

非常感謝提前,亞歷克斯

回答

0

我可以對我自己弄明白:

在我加入

@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; 

(增加了下劃線),現在它的工作再次完美。

其實我很好奇爲什麼它的工作之前,但我不打算進一步調查。