也许有人可以帮我解决这个奇怪的事情:
如果用户单击按钮,则会将新的UITableView推送到导航控制器.这个新视图正在进行一些数据库查询,这需要一些时间.因此我想在后台进行加载.
什么工作没有泄漏内存(但冻结屏幕,直到一切都完成):
WorkController *tmp=[[WorkController alloc] initWithStyle:UITableViewStyleGrouped];
self.workController=tmp;
[tmp release];
[self.workController loadList]; // Does the DB Query
[self.workController pushViewController:self.workController animated:YES];
Run Code Online (Sandbox Code Playgroud)
现在我试着这样做:
// Show Wait indicator
....
WorkController *tmp=[[WorkController alloc] initWithStyle:UITableViewStyleGrouped];
self.workController=tmp;
[tmp release];
[self performSelectorInBackground:@selector(getController) withObject:nil];
}
-(void) getController {
[self.workController loadList]; // Does the DB Query
[self.navigationController pushViewController:self.workController animated:YES];
}
Run Code Online (Sandbox Code Playgroud)
这也有效,但是内存泄漏,我不知道为什么!你能帮我吗 ?
顺便说一下 - 应用程序是否可能因内存泄漏而进入AppStore?或者首先检查一下?
提前致谢 !
我收到此代码的错误 -
警告:类'BeatMaker'未实现'AVAudioPlayerDelegate'协议
-(IBAction)playBeat3 {
NSString *path = [[NSBundle mainBundle] pathForResource:@"beat3" ofType:@"mp3"];
AVAudioPlayer* theAudio=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
theAudio.delegate = self;
[theAudio play];
}
Run Code Online (Sandbox Code Playgroud)
谁能帮我这个?
嘿 - 当我使用这行代码时,有人知道为什么我会泄漏吗??? :
[self setModules:[[aDictionary objectForKey:KEY_MODULES] mutableCopy]];
Run Code Online (Sandbox Code Playgroud)
在此先感谢pk
她在我的程序中使用这个编码
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docsPath = [paths objectAtIndex:0];
NSString *imageCacheDirPath = [docsPath stringByAppendingPathComponent:@"Image"];
NSString *imageCachePath = [imageCacheDirPath stringByAppendingPathComponent:@"1.jpg"];
[[NSFileManager defaultManager] createFileAtPath:imageCachePath contents:dataObj attributes:nil];
Run Code Online (Sandbox Code Playgroud)
我的编码有什么问题.发现一些示例代码.
我有一个我想修剪的字符串,如果它有超过11个字符.如果是这种情况,应将其修剪为11个字符,并附加"..."!你会建议最好的做法是什么?我来了,stringByPaddingToLength但也许是更好的方式!Thx提前!
NSArray *Lines = [StringData componentsSeparatedByString:@"\n"];
for (NSArray *ThisLine in Lines){
NSArray *Items = [ThisLine componentsSeparatedByString:@","];
...
}
Run Code Online (Sandbox Code Playgroud)
我收到警告NSArray可能无法响应componentsSeparatedByString.
有什么想法吗?
我使用Xcode 4在iPhone iOS上开展项目.
使用Xcode>产品>分析我得到35个问题,所有这些类型:
myTextField.text = [[NSString alloc] initWithFormat:@"0.2f", abc];
Run Code Online (Sandbox Code Playgroud)
问题是"分配给......的对象的潜在泄漏"
什么是有害物体,我该如何释放它?
谢谢
我正在对我的应用程序进行最后润色,并且由于某种原因,值不会显示为小数值.
if ( row == 0 ) {
float number1 = ([initamount.text floatValue ]);
initamount.text = [[NSString alloc]initWithFormat:@"%2.f Yard", number1];
double answer = number1 *3;
result.text = [[NSString alloc]initWithFormat:@"%2.f Feet", answer];
}
Run Code Online (Sandbox Code Playgroud)
这是代码我真的很累,可能会遗漏一些东西.
CLLocation *useOne = [[CLLocation alloc] initWithLatitude:40.074744 longitude:116.240179];
CLLocation *useTwo = [[CLLocation alloc] initWithLatitude:40.079106 longitude:116.243469];
CLLocationDistance distance = [useOne distanceFromLocation:useTwo];
NSLog(@"%d",distance);
Run Code Online (Sandbox Code Playgroud)
但我得到的结果是"距离= 1921570242"米.绝对这个结果是不正确的.
那我在哪里错了?
我不是一个非常优秀的程序员,所以如果这是一个愚蠢的问题原谅我!我只是在ios中学习图像转换我想在按钮点击事件中将图像从一个位置转换为另一个位置这里是代码...
- (IBAction)showinfobybutton:(id)sender {
CGFloat v1 = imageview.center.x;
CGFloat v2 = imageview.center.y;
CGAffineTransform trans = CGAffineTransformTranslate(imageview.transform, v1, v2);
imageview.transform = trans;
}
Run Code Online (Sandbox Code Playgroud)
代码有什么问题.它只能在y方向上转换而不是在x中转换.无论你为v1函数放多少值都不在乎.任何想法发生了什么......我完全被困了谢谢你的任何帮助
objective-c ×6
iphone ×4
ios ×3
memory-leaks ×2
xcode ×2
ios-4.2 ×1
ios4 ×1
ipad ×1
nsstring ×1
xcode4 ×1