我想在滚动时禁用重新加载表视图。现在,当用户滚动 uitableview 时,我的应用程序cellForRowAtIndexPath已被召回。如何在 srcolling 时禁用它?请给我一些建议。提前致谢。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *CellIdentifier = [NSString stringWithFormat:@"%d,%d",indexPath.section,indexPath.row];
UITableViewCell *cell = [_tableView dequeueReusableCellWithIdentifier:CellIdentifier];
UILabel *FileNameLabel;
UILabel *UploadTimeLabel;
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
CFileNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(40, 0, 130, 30)];
UploadTimeLabel = [[UILabel alloc] initWithFrame:CGRectMake(40, 20, 130, 25)];
FileNameLabel.tag = 1000;
FileNameLabel.backgroundColor = [UIColor clearColor];
FileNameLabel.font = [UIFont fontWithName:@"Helvetica" size:14];
FileNameLabel.font = [UIFont boldSystemFontOfSize:14];
FileNameLabel.textColor = [UIColor blackColor];
// FileNameLabel.text =[temp objectAtIndex:indexPath.row]; …Run Code Online (Sandbox Code Playgroud) 如果我有一个方法将动画附加到a UI Element,而不是将此方法的代码复制/粘贴到许多viewcontrollers,我可以创建一个class来保存方法,然后导入它吗?
我认为category在这个实例中使用a是没有意义的,因为我需要多个这个方法viewcontrollers,而a category是单个的扩展viewcontroller.
我正在使用'插件'SWRevealViewController帮助在我的应用程序中生成侧边栏.现在在objective-C中,您可以使用以下代码控制侧栏:
[self.sidebarButton setTarget: self.revealViewController];
[self.sidebarButton setAction: @selector( revealToggle: )];
[self.view addGestureRecognizer:self.revealViewController.panGestureRecognizer];
Run Code Online (Sandbox Code Playgroud)
sidebarButton已被连接到UIBarButtonItem和IBOutlet.现在我试图将它应用于我的Swift代码,并且我取得了成功.
我已经设置了一个@IBOutlet var按钮.现在我尝试了UIBarButtonItem和UIButton.当我尝试UIBarButtonItem时,我使用了以下行:
button = UIBarButtonItem(barButtonSystemItem: .Add, target: self.revealViewController(), action: "revealToggle:")
Run Code Online (Sandbox Code Playgroud)
但是,这没有任何作用,按钮不起作用.但是,如果我将按钮设置为UIButton并将其与以下内容挂钩:
button.addTarget(self.revealViewController(), action:"revealToggle:", forControlEvents:UIControlEvents.TouchUpInside)
Run Code Online (Sandbox Code Playgroud)
这可以将栏滑出而不是通过手势.问题是我无法将UIButton添加到工具栏(无论如何都在StoryBoard中).
那么有没有办法正确实现这个?此外,是否可以添加手势识别器?
谢谢
编辑
好吧,我已经设法让手势切换工作,虽然我认为我的方法有点长篇大论:
var swipeRight = UISwipeGestureRecognizer(target: self.revealViewController(), action: "revealToggle:")
swipeRight.direction = UISwipeGestureRecognizerDirection.Right
self.view.addGestureRecognizer(swipeRight)
var swipeLeft = UISwipeGestureRecognizer(target: self.revealViewController(), action: "revealToggle:")
swipeLeft.direction = UISwipeGestureRecognizerDirection.Left
self.view.addGestureRecognizer(swipeLeft)
Run Code Online (Sandbox Code Playgroud)
所以请更正.
我已经阅读了其他StackOverflow问题和解答,并了解这是自iOS6以来的一个错误(或者通过设计,必须解除分配代理,然后查看,谁知道).我不知道为什么或如何没有修复.
Anywho,我已经从其他答案添加了热门修补程序(下面,对于未来的读者):
- (void) viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
[self applyMapViewMemoryHotFixOnDisappear];
}
- (void)applyMapViewMemoryHotFixOnDisappear{
[self applyMapViewMemoryHotFix];
self.mapView.showsUserLocation = NO;
self.mapView.delegate = nil;
self.locationManager.delegate = nil;
[self.mapView removeFromSuperview];
self.mapView = nil;
}
- (void)applyMapViewMemoryHotFix{
switch (self.mapView.mapType) {
case MKMapTypeHybrid:
{
self.mapView.mapType = MKMapTypeStandard;
}
break;
case MKMapTypeStandard:
{
self.mapView.mapType = MKMapTypeHybrid;
}
break;
default:
break;
}
self.mapView.mapType = MKMapTypeStandard;
}
-(void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated
{
[self applyMapViewMemoryHotFix];
}
Run Code Online (Sandbox Code Playgroud)
但是,我的问题是,为什么内存不会降到MapKit级别之前?

还有什么我想念的吗?这是预期的行为吗?分析器判断没有内存泄漏,但显然有些事情是不对的......
我需要一个视图控制器供用户裁剪和旋转图像.
我认为iOS8照片应用程序所做的UI非常棒
但我发现只有这两个:
https://github.com/heitorfr/ios-image-editor
https://github.com/kishikawakatsumi/PEPhotoCropEditor
这些是有用的,但是当使图像小于裁剪区域时,移动或旋转图像非常困难,并且响应非常奇怪.
使用这些后,我认为iOS8照片应用程序的裁剪和旋转功能要好得多
所以是否有一个视图控制器执行图像裁剪和旋转像iOS 8照片应用程序?
解析日期时遇到一些问题。我有一系列受支持的格式,一旦从API接收到日期(字符串),我就会尝试解析这些格式的迭代,直到获得有效的NSDate对象。
Xcode Playground的一个片段-
let dateString = "02/06/1987" // --> want to parse into this Feb 6, not Jun 2
let dateFormatIncorrect = "dd.MM.yyyy"
let dateFormatCorrect = "MM/dd/yyyy"
let dateFormatter = NSDateFormatter()
dateFormatter.dateFormat = dateFormatIncorrect
let date = dateFormatter.dateFromString(dateString)! // "Jun 2, 1987, 12:00 AM"
dateFormatter.dateFormat = dateFormatCorrect
let date2 = dateFormatter.dateFromString(dateString)! // "Feb 6, 1987, 12:00 AM"
Run Code Online (Sandbox Code Playgroud)
为什么即使给定的字符串格式明显不正确,也为什么要解析日期?在文档中找不到有关日期格式化程序的任何内容,忽略了分隔符。
我意识到正确的解决方案是从API返回固定格式,但想知道这里发生了什么?
谢谢。
我正在开发一个应用程序,我必须从iPhone的麦克风执行录制,但我的要求是仅在某个特定频率下录制语音.所有其他超过此频率的声音都不应该记录.
我知道SO已经有很多帖子,但我找不到任何帮助.
我通过使用此代码找到频率: - http://www.ehow.com/how_12224909_detect-blow-mic-xcode.html
但是我很难避免记录这个频率.
任何人都可以建议我如何做到这一点或任何lib /开源可用.任何有关这方面的帮助将不胜感激.
提前致谢.
我想修剪用EZAudioRecorder录制的音频.
我正在编写此代码来修剪音频.这对于使用AVAudioRecorder录制的音频工作正常但是它会触发EZAudioRecorder的错误阻止,错误无法打开文件.
-(BOOL)trimAudiofile{
float audioStartTime=1.0;
float audioEndTime=2.0;//define end time of audio
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd_HH-mm-ss"];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES);
NSString *libraryCachesDirectory = [paths objectAtIndex:0];
libraryCachesDirectory = [libraryCachesDirectory stringByAppendingPathComponent:@"Caches"];
NSString *OutputFilePath = [libraryCachesDirectory stringByAppendingFormat:@"/output_%@.m4a", [dateFormatter stringFromDate:[NSDate date]]];
NSURL *audioFileOutput = [NSURL fileURLWithPath:OutputFilePath];
NSURL *audioFileInput=[self testFilePathURL];//<Path of orignal audio file>
if (!audioFileInput || !audioFileOutput)
{
return NO;
}
[[NSFileManager defaultManager] removeItemAtURL:audioFileOutput error:NULL];
AVAsset *asset = [AVAsset assetWithURL:audioFileInput];
AVAssetExportSession …Run Code Online (Sandbox Code Playgroud) 我只想知道当设备连接到 wifi 但调制解调器没有互联网连接时如何检测 iOS 中的互联网连接。
我使用了苹果和 AFNetworking 的可达性,但它们只检查连接性并返回连接标志,即使调制解调器中没有可用的互联网。
我的问题很简单.有人可以告诉我如何在UIWebView收到的URL中获取查询字符串参数.在目标c中它很容易,但我需要一些快速的帮助,因为我是这门语言的新手.提前致谢.
ios ×10
objective-c ×5
ios8 ×3
swift ×3
avfoundation ×1
cocoa-touch ×1
ezaudio ×1
image ×1
mapkit ×1
memory-leaks ×1
oop ×1
uitableview ×1
uiwebview ×1