在我们的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) 这是我的问题的更新.程序中止时我现在收到此警告. 警告:尝试使用不在框架中的块创建USE_BLOCK_IN_FRAME变量.
我找不到有关这意味着什么的更多信息.
这令我感到困惑.我收到EXC_BAD_ACCESS错误.我有NSZombieEneabled(它帮助解决了早期的问题),但是没有要跟踪的调用堆栈.
我有一些几乎相同的代码,相对于另一个获取的结果控制器.
这似乎与作业实体及其关联的客户实体之间的关系有关.关系是[作业实体] << - > [客户实体].
最初,我看到代码在没有错误的情况下工作,其中对应于所选行的作业实体没有通过关系链接的客户端实体.因此,在失败的情况下,这指向客户端实体,但是当它没有失败时,指针为零.
当我遇到这个问题时,我启动应用程序并直接进入作业选择器视图并选择一个单元格.就在那时,问题就出现了.
我做了一个实验,首先启动应用程序并转到客户端选择器视图,因为知道所有客户端实体都会进行提取.然后我去了工作选择器视图并选择了一个单元格.问题没有发生.
由于我只是尝试将指针传递给已经获取的作业实体,因此我不明白发生了什么.
顺便说一下,在我切换到使用NSFetchedResultsControllers之前,代码工作正常.我喜欢他们能为我做的事情,但这里有一些动态,我还没想到.
日志记录没有向我展示解决问题的任何理解.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
userState.selectedJob = [self.fetchedResultsController objectAtIndexPath:indexPath];
NSLog(@"\n\n(1 Pick) indexPath: %@\n",indexPath);
NSLog(@"\n\n(1 Pick) userState: %@\n",userState);
NSLog(@"\n\nnumber of Objects in job fetchresultscontroller = %d", [[fetchedResultsController fetchedObjects] count] );
NSLog(@"\n\n(1 Pick) selected job: %@\n",[self.fetchedResultsController objectAtIndexPath:indexPath]); // This line is causing the problem...
NSLog(@"\n\n(1 Pick) selected job: %@\n",userState.selectedJob); // Omitting the line above, this line fails
[self.navigationController pushViewController:userState.jobInfoTVC animated:YES];
}
Run Code Online (Sandbox Code Playgroud)
调试输出是
2011-05-07 09:27:04.142 job1[6069:207] …Run Code Online (Sandbox Code Playgroud) exc-bad-access core-data nsfetchedresultscontroller nszombieenabled
我有一个用链接器标志EXC_BAD_ACCESS调用的时候objc_setAssociatedObject:-weak_library /usr/lib/libSystem.B.dylib链接器标志.
我绝对需要链接器标志因为这个,有人知道一个解决方法吗?
(我也遇到了崩溃,dispatch_async但我可以解决这个问题...另外,我正在我的应用程序上构建iOS 4兼容的iOS 3兼容功能)
因为这么多个小时,我被困在一个愚蠢的坏访问.我完全找不到它.我希望你们中的一些人能够向我展示答案.在下面的代码中它出现在行上:NSString * stringCallVisit = [[NSString alloc]initWithFormat:.....
我无法理解,除参数theIntervention外,所有对象都是方法的本地对象.
如果我评论该方法NSString * stringCallVisit = [[NSString alloc]initWithFormat:...,即使我这样做id obj = callVisit.injectionby;,也不会出现不良访问; 所以我认为不良访问不是来自callVisit对象,而是来自stringCallVisit对象.但是为什么我只是在出现坏访问的时候实例化它.
谢谢你的帮助,
-(NSString*)getCallVisitForIntervention:(Intervention*)theIntervention
{
NSManagedObjectContext *context = [iPad_TestAppDelegate mainContext];
NSError *error;
NSFetchRequest *requestCallVisit = [[NSFetchRequest alloc]init];
[requestCallVisit setEntity:[NSEntityDescription entityForName:@"CallVisit" inManagedObjectContext:context]];
NSPredicate *predicateInterventionID = [NSPredicate predicateWithFormat:@"intervention_id = %@",theIntervention.id];
[requestCallVisit setPredicate:predicateInterventionID];
NSMutableArray *callVisits = [[context executeFetchRequest:requestCallVisit error:&error]mutableCopy];
NSString *xml = @"<CallVisits>";
for(CallVisit *callVisit in callVisits)
{
NSString * stringCallVisit = [[NSString alloc]initWithFormat:
@"<CallVisit>"
"<id>%@</id>"
"<injectionby>%@</injectionby>"
"<injectionspot>%@</injectionspot>"
"<intervention_id>%@</intervention_id>"
"<fls>%d</fls>"
"<weight>%d</weight>"
"<height>%d</height>"
"<painAtInjection>%d</painAtInjection>" …Run Code Online (Sandbox Code Playgroud) 我的应用程序有时会在完全加载到以下行之前崩溃:
if (![__persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&error])
Run Code Online (Sandbox Code Playgroud)
这个if状态所在的完整方法如下(我认为这是非常标准的):
- (NSPersistentStoreCoordinator *)persistentStoreCoordinator
{
if (__persistentStoreCoordinator != nil) {
return __persistentStoreCoordinator;
}
NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"CoreData.sqlite"];
NSError *error = nil;
__persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedObjectModel]];
if (![__persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&error]) {
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
abort();
}
return __persistentStoreCoordinator;
}
Run Code Online (Sandbox Code Playgroud)
更新
第二次-(NSPersistentStoreCoordinator *)persistentStoreCoordinator调用该方法时发生崩溃.编辑
从第一个可见的viewController调用它的第一次:
- (void)updateStats {
NSLog(@"Updating stats");
dispatch_queue_t request_queue = dispatch_queue_create("updateNumberOfSchedules", NULL);
dispatch_async(request_queue, ^{
AppDelegate *theDelegate = (AppDelegate …Run Code Online (Sandbox Code Playgroud) 我这样称之为我的实用方法:
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
[dateFormat setDateFormat:@"dd.MM.yy HH:mm"];
NSString *dateString = [dateFormat stringFromDate:[NSDate date]];
return [[Environment sharedInstance].versionLabelFormat replaceTokensWithStrings:
@"VERSION", APP_VERSION,
@"BUILD", APP_BULD_NUMBER,
@"DATETIME" , dateString,
nil ];
Run Code Online (Sandbox Code Playgroud)
这是NSString类别方法
-(NSString *)replaceTokensWithStrings:(NSString *)firstKey, ... NS_REQUIRES_NIL_TERMINATION{
NSString *result = self;
va_list _arguments;
va_start(_arguments, firstKey);
for (NSString *key = firstKey; key != nil; key = va_arg(_arguments, NSString*)) {
// The value has to be copied to prevent crashes
NSString *value = [(NSString *)(va_arg(_arguments, NSString*))copy];
if(!value){
// Every key has to …Run Code Online (Sandbox Code Playgroud) 使用我目前的iOS 5应用程序在iOS 6上进行测试时,我遇到了一些错误.
我们已经经历了一个方法返回的锁定,这个方法返回一个内部使用块的无害方法,但不是属性.问题是调用方法是有效的,方法中的每一行代码都是有效的(包括使用代码的块)
我在调用块之前尝试使用[块复制],但绝对没有变化.
示例项目,使用Google Analytics [Xcode Project] [1]
实际上我已经为谷歌分析创建了一个手机插件.我的代码似乎工作正常,但当我尝试将我的代码添加到现有项目时,我的错误是错误的.我真的无法找到为什么代码可以在一个新项目上工作,但不能在一个旧项目上工作.
代码在新项目中非常有效.我可以在分析仪表板中看到数据,一切正常
我有一个UITableViewCell,它有一个地图视图作为子视图.创建了一个Custom类,它处理所有操作,如添加注释,委托等,并将其命名为CustomeMap.swift.
之后,我改变了地图视图类的名称,CustomeMap在小区厦门国际银行,在应用程序崩溃,有时initWithCoder的方法CustomeMap,因为我还没有实现这个方法.后来我添加了如下方法:
import UIKit
import MapKit
protocol CustomeMapDelegate{
func annotationClickEvent(info:NSDictionary?)
}
class CustomeMap: MKMapView,MKMapViewDelegate,CLLocationManagerDelegate {
var locationManager:CLLocationManager?
var delegate1:CustomeMapDelegate?
var tap:UITapGestureRecognizer?
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
override func awakeFromNib()
{
if CLLocationManager.authorizationStatus() == CLAuthorizationStatus.AuthorizedAlways {
self.showsUserLocation = true;
}
else
{
locationManager = CLLocationManager()
locationManager?.delegate = self;
if locationManager!.respondsToSelector("requestAlwaysAuthorization")
{
locationManager?.requestAlwaysAuthorization()
}
}
self.delegate = self
self.userInteractionEnabled = true
tap = UITapGestureRecognizer(target: self, action: "calloutAction:") …Run Code Online (Sandbox Code Playgroud) 我有来自Crashlytics的这样一份报告:
Thread : Crashed: com.apple.main-thread
0 libobjc.A.dylib 0x000000019503fbd0 objc_msgSend + 16
1 CoreFoundation 0x00000001836e5458 CFRelease + 524
2 CoreFoundation 0x00000001836f1a18 -[__NSArrayM dealloc] + 152
3 libobjc.A.dylib 0x0000000195045724 (anonymous namespace)::AutoreleasePoolPage::pop(void*) + 564
4 CoreFoundation 0x00000001836e9074 _CFAutoreleasePoolPop + 28
5 Foundation 0x000000018461a588 -[NSAutoreleasePool release] + 148
6 UIKit 0x00000001882b4460 -[UIApplication _run] + 588
7 UIKit 0x00000001882aefac UIApplicationMain + 1488
Run Code Online (Sandbox Code Playgroud)
有什么办法可以解决这个问题吗?它发生在客户设备上,所以我没有机会重现它.
exc-bad-access ×10
ios ×7
iphone ×4
objective-c ×4
cocoa-touch ×2
core-data ×2
html5-video ×1
ios8 ×1
mapkit ×1
mkmapview ×1
swift ×1
uiwebview ×1