释放MKMapView后,我发生了一次奇怪的(?)崩溃.MKMapView是我的视图控制器中的一个子视图,在我从导航堆栈中删除该视图并释放它后,应用程序崩溃:
...
#4 0x34196dc8 in -[MKMapView(UserPositioningInternal) locationManagerFailedToUpdateLocation:withError:]
#5 0x3417030c in -[MKLocationManager _reportLocationFailureWithError:]
#6 0x3416de94 in -[MKLocationManager locationManager:didFailWithError:]
#7 0x3205f538 in -[CLLocationManager onClientEventLocation:]
#8 0x3205dd5c in -[CLLocationManager onClientEvent:supportInfo:]
...
Run Code Online (Sandbox Code Playgroud)
处理我的视图时是否必须执行一些额外的步骤?
编辑: 在控制器的dealloc方法中将mapView.showsUserLocation设置为NO似乎有所帮助.问题仍然是 - 它是否有意?
快问你的问题.我希望能够创建一个对象的实例.对象类型基于字符串.
在php中你可以用一个字符串替换类名,但是我怀疑它在Objective c中是那么容易.
NSString * className;
id theObject;
className = @"TestObject";
theObject = [[className alloc] init];
Run Code Online (Sandbox Code Playgroud)
这是对它可能的样子的分解.我想尝试避免使用巨大的案例风格声明.
是否可以使用选择器系统?
有任何想法吗?
干杯
当我完成它们时,这些日期指针中的任何一个或两个都需要[发布].我怎么知道这个?我不确定,因为我没有明确地做init.
NSDate *date = [NSDate date];
NSDate *date = [dateWithTimeIntervalSince1970:100000000];
Run Code Online (Sandbox Code Playgroud) 我是iphone开发的新手.我有一个问题.我想在NSString中转换NSTimeInterval值,但在此不成功.请快速查看下面的代码.
在.h
NSTimeInterval startTime;
NSTimeInterval stopTime;
NSTimeInterval duration;
Run Code Online (Sandbox Code Playgroud)
在.m
startTime = [NSDate timeIntervalSinceReferenceDate];
stopTime = [NSDate timeIntervalSinceReferenceDate];
duration = stopTime-startTime;
NSLog(@"Duration is %@",[NSDate dateWithTimeIntervalSinceReferenceDate: duration]);
NSLog(@"Duration is %@", [NSString stringWithFormat:@"%f", duration]);
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateStyle:NSDateFormatterMediumStyle];
NSString *time = [dateFormatter stringFromDate:duration];----> Error
[dateFormatter release];
Run Code Online (Sandbox Code Playgroud)
并在一个标签上设置此字符串----
[timeLabel setText:time];
Run Code Online (Sandbox Code Playgroud)
但它不起作用它显示错误:'stringFromDate:'的参数1的不兼容类型
如果我评论该行,它会在控制台窗口中显示正确的持续时间.
谢谢你的帮助.
我尝试在我的应用程序中播放一些音频,它工作正常3次.但是当我试图在第四次播放时它会显示错误.错误域= NSOSStatusErrorDomain代码= -43"操作无法完成.(OSStatus错误-43.)".代码是
NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/Sun.wav", [[NSBundle mainBundle] resourcePath]]];
NSError *error;
AudioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
AudioPlayer.numberOfLoops = 0;
AudioPlayer.volume=1.0;
if (AudioPlayer == nil)
{
NSLog([error description]);
}
else
[AudioPlayer play];
Run Code Online (Sandbox Code Playgroud)
有人在......之前搞清楚了吗?
从iOS编程课程(cs193p fall2010)学习一些示例代码我遇到了sbjson框架,该框架通过名为SBJSON的类别扩展了NSObject等.但在+标题"NSObject + SBJSON.h"中,它读作:
@interface NSObject (NSObject_SBJSON)
Run Code Online (Sandbox Code Playgroud)
NSObject_SBJSON到SBJSON的魔术映射来自哪里?我注意到xcode在下划线之前接受了任何字符串!
但没有发现任何暗示.
thanx klaus
有人可以帮我将NSObject转换为NSString吗?
我正在尝试做这样的事情 -
NSString *address = [NSString stringWithFormat:ivpObj.addressStr];
Run Code Online (Sandbox Code Playgroud)
但我得到了一个警告 - 格式不是字符串文字,也没有格式参数
请一些帮助
我有一个类,其中有两个方法_addView()和_removeView().
这些方法我在另一个类中使用添加视图和删除视图,但它不工作.如果我在使用相同的工作.
删除 -
- (id)deleteBoxAtIndex:(int)boxIndex{
for (int i = 0; i < [[self subviews] count]; i++ ) {
[[[self subviews] objectAtIndex:boxIndex] removeFromSuperview];
}
return self;
}
Run Code Online (Sandbox Code Playgroud)
然后我如何计算该类中的子视图或从该类中删除.
我希望你能帮我解决这个"小问题".我想将一个字符串转换为double/float.
NSString *stringValue = @"1235";
priceLabel.text = [NSString stringWithFormat:@"%d",[stringValue doubleValue]/(double)100.00];
Run Code Online (Sandbox Code Playgroud)
我希望这可以将价格标准设置为12,35,但我得到一些奇怪的长字符串对我来说没有任何意义.
我试过了:
priceLabel.text = [NSString stringWithFormat:@"%d",[stringValue intValue]/(double)100.00];
priceLabel.text = [NSString stringWithFormat:@"%d",[stringValue doubleValue]/100];
Run Code Online (Sandbox Code Playgroud)
但都没有成功.
我用ASIHTTPReqeust下载文件.一切都下载得很好,但它无法将文件从临时目录移动到文档.当我实施
-(void) request:(ASIHTTPRequest *)request didReceiveData:(NSData *)data
Run Code Online (Sandbox Code Playgroud)
请求失败并显示错误.但文件已下载.
如果我删除此实现,一切都很好,文件正在转移到文档.这是错误文本:
Error Domain=ASIHTTPRequestErrorDomain Code=8 "Failed to move file from '/var/folders/Qu/Qu0o0VcpEY4npJr2C1yPzE+++TI/-Tmp-/Skrillex feat. Nero - Wobbleland.mp3' to '/Users/Timur/Library/Application Support/iPhone Simulator/4.3/Applications/34389282-4013-4354-95D9-DF2847B4EE55/Documents/Audio/Skrillex feat. Nero - Wobbleland.mp3'" UserInfo=0x5949520 {NSUnderlyingError=0x59992a0 "The operation couldn’t be completed. (Cocoa error 4.)", NSLocalizedDescription=Failed to move file from '/var/folders/Qu/Qu0o0VcpEY4npJr2C1yPzE+++TI/-Tmp-/Skrillex feat. Nero - Wobbleland.mp3' to '/Users/Timur/Library/Application Support/iPhone Simulator/4.3/Applications/34389282-4013-4354-95D9-DF2847B4EE55/Documents/Audio/Skrillex feat. Nero - Wobbleland.mp3'}
Run Code Online (Sandbox Code Playgroud)
谁有类似的问题?
objective-c ×8
iphone ×6
categories ×1
class ×1
crash ×1
creation ×1
double ×1
filesystems ×1
header-files ×1
ios ×1
ios4 ×1
mkmapview ×1
nsdate ×1
nsobject ×1
nsstring ×1
release ×1
xcode ×1