我想知道为什么我分配的对象重用了之前使用过的地址。
情景是这样的:
这是用于创建/附加MenuVC到SlideNavigationController
的方法/功能-(void)setupSlideNavigation:(SlideNavigationController *)sn
{
MenuVC *menuVC = [[MenuVC alloc] initWithNibName:@"MenuVC" bundle:nil];
UIBarButtonItem *leftItem = [[UIBarButtonItem alloc]
initWithImage:[UIImage imageNamed:@"setting_btn_09.png"]
style:UIBarButtonItemStylePlain
target:nil
action:nil];
UIEdgeInsets edges = UIEdgeInsetsMake(0, -16, 0, 0);
leftItem.imageInsets = edges;
sn.leftMenu = menuVC;
sn.leftbarButtonItem = leftItem;
}
UVC1 和 UVC2 由此设置:
-(void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[[UIUtils sharedInstance] setupSlideNavigation:(SlideNavigationController*)self.navigationController];
}
也发生在我创建LoginViewController时:
[[LoginViewController alloc] initWithNibName:@"LoginViewController" bundle:nil] //called from viewDidLoad method of the MenuVC
此行为导致“应用程序尝试以模态方式呈现活动控制器”
我还使用了ios / objc / compiler
的“自动释放”机制