Hello在iOS6上的模拟器中发生错误.
*** Terminating app due to uncaught exception 'UIViewControllerHierarchyInconsistency', reason: 'A view can only be associated with at most one view controller at a time! View <UIView: 0xa3ae880; frame = (0 0; 320 367); autoresize = W+H; layer = <CALayer: 0xa3ae8e0>> is associated with <SearchHotelsViewController: 0xa3a6a20>. Clear this association before associating this view with <SecondViewController: 0xa1a9e90>.'
Run Code Online (Sandbox Code Playgroud)
初始化代码
UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"????? ?????", @"????? ?????", nil]];
segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar;
self.navigationItem.titleView = segmentedControl;
[segmentedControl addTarget:self action:@selector(changeSegments:) forControlEvents:UIControlEventValueChanged];
segmentedControl.selectedSegmentIndex = …Run Code Online (Sandbox Code Playgroud) Hello当安装应用程序时,它会要求用户发送推送通知的权限.我正在测试我的应用程序.但是从设备中删除后再安装它不再需要许可.如何删除这些设置以便再次请求权限?
我需要它来测试服务器推送通知.
对项目进行代码分析,在[defaults setObject: deviceUuid forKey: @“deviceUuid”]行上得到“ Reference-counted object is used after it release”的提示;
我看了这个话题 Obj-C,Reference-counted object 释放后使用? 但是没有找到解决办法。ARC 禁用。
// Get the users Device Model, Display Name, Unique ID, Token & Version Number
UIDevice *dev = [UIDevice currentDevice];
NSString *deviceUuid;
if ([dev respondsToSelector:@selector(uniqueIdentifier)])
deviceUuid = dev.uniqueIdentifier;
else {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
id uuid = [defaults objectForKey:@"deviceUuid"];
if (uuid)
deviceUuid = (NSString *)uuid;
else {
CFStringRef cfUuid = CFUUIDCreateString(NULL, CFUUIDCreate(NULL));
deviceUuid = (NSString *)cfUuid;
CFRelease(cfUuid);
[defaults setObject:deviceUuid forKey:@"deviceUuid"];
}
} …Run Code Online (Sandbox Code Playgroud)