我正在使用ARC专门为iOS 5开发.应该IBOutlets UIView(和子类)是strong或weak?
下列:
@property (nonatomic, weak) IBOutlet UIButton *button;
Run Code Online (Sandbox Code Playgroud)
将摆脱所有这一切:
- (void)viewDidUnload
{
// ...
self.button = nil;
// ...
}
Run Code Online (Sandbox Code Playgroud)
这样做有什么问题吗?模板正在使用strong,当从"Interface Builder"编辑器直接连接到标题时创建的自动生成属性,但为什么?在UIViewController已经有一个strong到其基准view保留其子视图.
cocoa-touch objective-c interface-builder ios automatic-ref-counting
我有一个多线程的应用程序,在我的所有测试机器上都非常稳定,并且对于几乎每个用户来说似乎都很稳定(基于没有崩溃的抱怨).该应用程序经常为一个用户崩溃,他们很友好地发送崩溃报告.所有崩溃报告(~10个连续报告)看起来基本相同:
Date/Time: 2010-04-06 11:44:56.106 -0700
OS Version: Mac OS X 10.6.3 (10D573)
Report Version: 6
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000002, 0x0000000000000000
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Thread 0 Crashed: Dispatch queue: com.apple.main-thread
0 com.apple.CoreFoundation 0x90ab98d4 __CFBasicHashRehash + 3348
1 com.apple.CoreFoundation 0x90adf610 CFBasicHashRemoveValue + 1264
2 com.apple.CoreText 0x94e0069c TCFMutableSet::Intersect(__CFSet const*) const + 126
3 com.apple.CoreText 0x94dfe465 TDescriptorSource::CopyMandatoryMatchableRequest(__CFDictionary const*, __CFSet const*) + 115
4 com.apple.CoreText 0x94dfdda6 TDescriptorSource::CopyDescriptorsForRequest(__CFDictionary const*, __CFSet const*, long (*)(void const*, void const*, void*), void*, unsigned long) …Run Code Online (Sandbox Code Playgroud) 我更新我的iOS应用程序,以取代UIWebView用WKWebView.但是我不明白如何实现相同的行为WKWebView.随着UIWebView我用scalesPageToFit,以确保网络PAG具有相同大小的屏幕尺寸显示(从而出现全屏幕无需滚动).
我在网络上找到了解决方案,但它不起作用:
- (void)webView:(WKWebView *)webView didCommitNavigation:(WKNavigation *)navigation {
NSString *javascript = @"var meta = document.createElement('meta');meta.setAttribute('name', 'viewport');meta.setAttribute('content', 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no');document.getElementsByTagName('head')[0].appendChild(meta);";
[webView evaluateJavaScript:javascript completionHandler:nil];
}
Run Code Online (Sandbox Code Playgroud) 在发布我的iOS应用程序的新版本后,我经常遇到以下崩溃.
崩溃:WebThread EXC_BAD_ACCESS KERN_INVALID_ADDRESS位于0x80000012
这是令人恼火的崩溃之一,其中堆栈跟踪没有提供任何与其崩溃或导致崩溃的原因相关的线索.一个主要的问题是这次崩溃只发生在iOS8中.请在下面找到堆栈跟踪:
0 libobjc.A.dylib objc_msgSend + 5 release
1 CoreFoundation CFRelease + 600
2 QuartzCore CA::release_objects(X::List<void const*>*) + 16
3 QuartzCore -[CAAnimation dealloc] + 54
4 libobjc.A.dylib objc_object::sidetable_release(bool) + 166
5 libobjc.A.dylib (anonymous namespace)::AutoreleasePoolPage::pop(void*) + 404
6 CoreFoundation _CFAutoreleasePoolPop + 16
7 Foundation -[NSAutoreleasePool drain] + 122
8 CFNetwork AutoAutoreleasePool::~AutoAutoreleasePool() + 24
9 CFNetwork ___ZN27URLConnectionClient_Classic18_withDelegateAsyncEPKcU13block_pointerFvP16_CFURLConnectionPK33CFURLConnectionClientCurrent_VMaxE_block_invoke_2 + 166
10 CFNetwork RunloopBlockContext::_invoke_block(void const*, void*) + 60
11 CoreFoundation CFArrayApplyFunction + 36
12 CFNetwork RunloopBlockContext::perform() + 182
13 CFNetwork MultiplexerSource::perform() …Run Code Online (Sandbox Code Playgroud) 在我们的iPad-App中,我们使用UIWebView从一个域加载不同的站点,其中一些使用hml5-Video加载.没有视频的网站可以完美加载.但是当我加载包含htmlt5-video的网站时,有时我的应用程序在使用EXC_BAD_ACCESS的UIWebView的加载过程中崩溃,有时它不会.每当发生这样的崩溃时,似乎发生在将视频播放器添加到站点中的位置.
我确实从Apple下载了UICatalog-Example,并且确实将WebViewController-Class中的Default-URL更改为包含html5-video的站点的URL.结果相同......有时崩溃有时不会崩溃.
我还在Xcode(基于视图的应用程序 - 用于iPad)上创建了一个新项目,并且只在新的Projects ViewController中添加了一个UIWebView.再次......加载包含html5-video的网站有时会导致崩溃,有时甚至不会.
"新项目"视图控制器代码(实施):
- (void)viewDidLoad {
[super viewDidLoad];
self.myWebView = [[[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 768, 1004)] autorelease];
self.myWebView.backgroundColor = [UIColor whiteColor];
self.myWebView.scalesPageToFit = YES;
self.myWebView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
self.myWebView.delegate = self;
[self.view addSubview: self.myWebView];
[self.myWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.gelbeseiten.de/129103114849"]]];
//More Sites with HTML5-Videos ...
//[self.myWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.gelbeseiten.de/129103746403"]]];
//[self.myWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.gelbeseiten.de/129105233646"]]];
}
- (void)viewDidUnload {
[super viewDidUnload];
self.myWebView = nil;
}
- (void)viewWillDisappear:(BOOL)animated {
[self.myWebView stopLoading];
}
- (void)dealloc {
myWebView.delegate = nil;
[myWebView release]; …Run Code Online (Sandbox Code Playgroud) objective-c ×3
ios ×2
iphone ×2
breakpoints ×1
cocoa ×1
cocoa-touch ×1
crash ×1
exception ×1
gdb ×1
html5-video ×1
ios8 ×1
macos ×1
uiwebview ×1
wkwebview ×1