我只在iOS9中遇到这个奇怪的错误:
[UIWindow endDisablingInterfaceAutorotationAnimated:] called on UITextEffectsWindow: ...without matching
-beginDisablingInterfaceAutorotation. Ignoring.
Run Code Online (Sandbox Code Playgroud)
我可以通过从我的collectionView中向下拖动来交互式地关闭键盘.我没有通过轻击手势或按Enter键解除键盘错误.这非常令人沮丧.即使我没有观察到任何键盘通知,我仍然会在此交互式键盘解除时收到此错误.我想知道是否有其他人遇到过这个错误并找到了解决方案.我有一个inputAccessoryView,由一个安装在键盘上的textView组成.
我试图使用NSNotificationCenter将NSDictionary表单UIView传递给UIViewController.字典在发布通知时工作正常,但在接收方法中,我无法访问字典中的任何对象.
这是我如何创建字典并发布通知...
itemDetails = [[NSDictionary alloc] initWithObjectsAndKeys:@"Topic 1", @"HelpTopic", nil];
[[NSNotificationCenter defaultCenter] postNotificationName:@"HotSpotTouched" object:itemDetails];
Run Code Online (Sandbox Code Playgroud)
在UIViewController中,我正在设置观察者......
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(hotSpotMore:)
name:@"HotSpotTouched"
object:nil];
Run Code Online (Sandbox Code Playgroud)
出于测试目的,hotSpotMore看起来像这样......
- (void)hotSpotMore:(NSDictionary *)itemDetails{
NSLog(@"%@", itemDetails);
NSLog(@"%@", [itemDetails objectForKey:@"HelpTopic"]);
}
Run Code Online (Sandbox Code Playgroud)
第一个NSLog工作正常,显示字典的内容.第二个日志抛出以下异常......
[NSConcreteNotification objectForKey:]: unrecognized selector sent to instance 0x712b130
Run Code Online (Sandbox Code Playgroud)
我不明白为什么我无法访问传递的字典中的任何对象.
在此先感谢您的帮助.
约翰
我注意到我的应用程序泄漏了内存,但如果我把MKMapView
内存问题消失了.
为了测试这个理论,我做了一个简单的项目,它有一个视图,用一个视图推入一个视图MKMapView
并弹出和推动.而已.视图控制器中没有代码,通过故事板完成.
如果我来回地图视图,在推送并弹出带有地图的视图后,它开始大约3MB,大约15倍的内存大约是230MB.
有人见过这个吗?看起来像一个很大的bug.是否有不同的使用方法MKMapView
可以防止它泄漏太多?
我有这个
- (void)loadView {
BOOL success;
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString* documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString* databasePath = [documentsPath stringByAppendingPathComponent:@"ProxDeals.db"];
NSError *error;
BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:databasePath];
if (fileExists==TRUE) {
[[NSBundle mainBundle] loadNibNamed:@"ProxDealsViewController" owner:self options:nil];
}
else {
NSString *defaultDBPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"ProxDeals.db"];
NSLog(@"%@",defaultDBPath);
success = [fileManager copyItemAtPath:defaultDBPath toPath:databasePath error:&error];
if (!success) {
NSAssert1(0, @"Failed to create writable database file with message '%@/.", [error localizedDescription]);
}
[[NSBundle mainBundle] loadNibNamed:@"UserRegistration" owner:self options:nil];
}
Run Code Online (Sandbox Code Playgroud)
}
而这个错误: …
我在返回heightForRowAtIndexPath时知道单元格的内容.在此函数中如何获取单元格对象?
- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
}
Run Code Online (Sandbox Code Playgroud)
如果我试试这个
[tableView cellForRowAtIndexPath:indexPath]
Run Code Online (Sandbox Code Playgroud)
它失败并在无限循环中消失.
任何的想法?
似乎UIView没有像" didRemoveFromSuperview
"或" willRemoveFromSuperview
" 那样的方法.那么,当UIView从superView中删除时,如何监听事件?我应该使用KVO吗?提前致谢!
如前所述 - 我是第一个订单的Objective-C新手,但是已经阅读了4本关于这个主题的实用书籍和一堆电子书和文档,我仍然无法找到我正在寻找的东西.
我有一个顶级内容视图控制器,它想要从应用程序委托的window属性的物理维度配置其视图属性.这是几个人已经问过的问题.([UIScreen mainScreen]
不会因为此论坛之前已经多次播出的原因而削减它).因此,逻辑方法是内容视图控制器读取应用程序委托窗口的框架.现在,我发现接近这个的唯一答案是使用[[[UIApplication sharedApplication] window] frame]
- 但是,这只有在窗口属性被设为keyAndVisible时才有效.内容视图控制器需要在获取makeKeyAndVisible 之前读取app delegate的window属性.代码按此顺序排列....
应用代表:
- (BOOL) application: (UIApplication *) application didFinishLaunchingWithOptions: (NSDictionary *) launchOptions {
// This next line is a test window frame for R&D purposes....
[self setWindow: [[UIWindow alloc] initWithFrame: CGRectMake(0.0f, 20.0f, 320.0f, 320.0f)]];
if ([self window]) {
contentViewController = [[ContentViewControl alloc] initWithNibName: nil bundle: nil]; // Content view controller instantiated here
if (contentViewController) {
[[self window] addSubview: [contentViewController view]];
[[self window] layoutSubviews]; …
Run Code Online (Sandbox Code Playgroud) 我在Objective-C中注意到以下内容,启用了ARC:
让我们有简单的A类和自动合成的弱属性
@interface A
@property (nonatomic, weak) id refObject;
@end
@implementation A
@end
Run Code Online (Sandbox Code Playgroud)
并且实现了dealloc的第二类B.
@interface B
@end
@implementation B
-(void) dealloc
{
NSLog(@"In dealloc");
}
@end
Run Code Online (Sandbox Code Playgroud)
最后,A类的某个地方有以下几点:
@implementation A
...
-(void) foo
{
B* b = [B new];
self.refObject = b;
// Just use b after the weak assignment
// in order to not dealloc 'b' before assignement
NSLog(@"%@", b);
}
...
@end
Run Code Online (Sandbox Code Playgroud)
如果我在中设置断点[B dealloc]
并检查[A refObject]
属性,我可以看到它a.refObject
是nil但a->_refObject
不是nil并且指向'b'
任何想法为什么会发生?
我尝试像这样安装Homebrew:
ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)"
Run Code Online (Sandbox Code Playgroud)
它没有正确安装所以我关闭终端并再次尝试.现在它显示以下消息:
It appears Homebrew is already installed. If your intent is to reinstall you
should do the following before running this installer again:
rm -rf /usr/local/Cellar /usr/local/.git && brew cleanup
Run Code Online (Sandbox Code Playgroud)
我试图这样做,但没有成功.将显示以下消息:
brew: command not found
Run Code Online (Sandbox Code Playgroud)
所以,问题是已经安装了Homebrew但实际上它没有安装.有什么建议如何解决这个问题?谢谢!
ios ×4
iphone ×4
objective-c ×3
accessor ×1
android ×1
homebrew ×1
ios9 ×1
ipad ×1
keyboard ×1
macos ×1
mainwindow ×1
memory-leaks ×1
methods ×1
mkmapview ×1
nsdictionary ×1
statusbar ×1
swift ×1
uiview ×1
xcode ×1