我想在我的应用程序中实现一个可隐藏的UITabBar.我已经设置了所有的动画,但它们的效果非常好.我只是在让我的UIButton"拉片"显示标签栏时遇到问题.它没有响应触摸事件UIControlEventTouchUpInside.我将拉片添加到UITabBarController中的UITabBar:
- (void)viewDidLoad
{
[super viewDidLoad];
//Add pull
pullButton = [UIButton buttonWithType:UIButtonTypeCustom];
UIImage *image = [UIImage imageNamed:@"TabBarPull.png"];
pullButton.frame = CGRectMake(self.tabBar.frame.size.width - image.size.width, -image.size.height + 3, image.size.width, image.size.height);
[pullButton setImage:image forState:UIControlStateNormal];
[pullButton addTarget:self action:@selector(pullBarTapped:) forControlEvents:UIControlEventTouchUpInside];
pullButton.userInteractionEnabled = YES;
[self.tabBar addSubview:pullButton];
}
Run Code Online (Sandbox Code Playgroud)
标签栏看起来像是打开和关闭的:

编辑:我已经确定问题是因为按钮落在UITabBar的框架之外.看起来我将不得不把按钮放在UITabBar ...动画噩梦之外.
我在一个透明的UIView下有一个UIScrollView.我需要将所有平移和点击转移到滚动视图(仅水平滚动).常规UIView使用UIPanGestureRecognizer的子类来跟踪垂直平移(此处找到的子类).在覆盖视图中,我覆盖触摸事件方法以将它们传递给UIScrollView.
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[super touchesBegan:touches withEvent:event];
[self.scrollView.panGestureRecognizer touchesBegan:touches withEvent:event];
[self.scrollView.singleTapGesture touchesBegan:touches withEvent:event];
}
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
{
[super touchesCancelled:touches withEvent:event];
[self.scrollView.panGestureRecognizer touchesCancelled:touches withEvent:event];
[self.scrollView.singleTapGesture touchesCancelled:touches withEvent:event];
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
[super touchesEnded:touches withEvent:event];
[self.scrollView.panGestureRecognizer touchesEnded:touches withEvent:event];
[self.scrollView.singleTapGesture touchesEnded:touches withEvent:event];
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
[super touchesMoved:touches withEvent:event];
[self.scrollView.panGestureRecognizer touchesMoved:touches withEvent:event];
[self.scrollView.singleTapGesture touchesMoved:touches withEvent:event];
}
Run Code Online (Sandbox Code Playgroud)
叠加视图,垂直平移工作完美.在UIScrollView中,水龙头也可以完美运行.滚动但不是那么多.滚动视图滚动大约三个点,然后停止(因为我继续使用水平平移.)如果我放开速度,滚动视图然后选择该速度并完成滚动.
导致滚动视图停止滚动然后获取速度的可能问题是什么?
在我的应用程序中,当用户进行应用内购买时,应用程序需要下载zip文件并将其解压缩到应用程序的文档文件夹中.zip文件下载并可以解压缩.我正在使用Objective Zip来解压缩档案.问题是,在尝试为每个文件创建文件夹路径时,永远不会创建文件夹,也没有错误.
以下是发生这种情况的部分的示例代码:
// Create file manager
NSFileManager *fileMgr = [NSFileManager defaultManager];
//Unzip
NSString *applicationDocumentsDir = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
ZipFile *unzipFile = [[ZipFile alloc] initWithFileName:[applicationDocumentsDir stringByAppendingPathComponent:[NSString stringWithFormat:@"%@.zip",@"Mid America Oireachtas 2011"]] mode:ZipFileModeUnzip];
NSArray *infos= [unzipFile listFileInZipInfos];
for (FileInZipInfo *info in infos) {
//NSLog(@"- %@ %@ %d (%d)", info.name, info.date, info.size, info.level);
// Locate the file in the zip
[unzipFile locateFileInZip:info.name];
// Expand the file in memory
ZipReadStream *read= [unzipFile readCurrentFileInZip];
NSMutableData *data= [[NSMutableData alloc] initWithLength:info.length];
int bytesRead = …Run Code Online (Sandbox Code Playgroud) 我正在通过互联网异步下载四个 plist 文件。我需要等到所有四个文件都下载完毕,直到我在第一次运行时推送 UIViewController 或在所有后续运行中刷新数据并重新加载我的所有 UITableViews。
在第一次运行时,一切正常。刷新时,所有四个 url 请求都被调用和启动,但从不调用它们的完成或失败块,并且 UI 冻结。这很奇怪,因为我在后台线程中执行所有操作。我一直无法弄清楚为什么会发生这种情况。
第一次加载和刷新方法以相同的方式调用四个“更新”方法,并以相同的方式使用 NSCondition。
对于第一次运行:
- (void)loadContentForProgram:(NSString *)programPath
{
NSLog(@"Start Load Program");
AppDelegate *myDelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
hud = [[MBProgressHUD alloc] initWithView:myDelegate.window];
[myDelegate.window addSubview:hud];
hud.labelText = @"Loading...";
hud.detailsLabelText = @"Loading Data";
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
//Do stuff here to load data from files
//Update From online files
hud.detailsLabelText = @"Updating Live Data";
resultLock = NO;
progressLock = NO;
recallLock = NO;
stageLock = NO;
condition = [[NSCondition alloc] init];
[condition lock]; …Run Code Online (Sandbox Code Playgroud) 我有一个UITableViewCell我要加五UIButtons.我以编程方式创建按钮,添加动作和图像.按钮放置在正确的位置,动作正常,标签已设置,但它们是清晰的.图像没有显示.
这是我用来创建其中一个按钮并将它们添加到单元格中,此代码位于tableView:cellForRowAtIndexPath::
if ([[self.compCompletion objectForKey:@"Key" isEqualToString:@"YES"]) {
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(11, 6, 21, 21);
button.tag = 1;
[button addTarget:self action:@selector(changeCompStatus:) forControlEvents:UIControlEventTouchUpInside];
[button setImage:[UIImage imageNamed:@"Comp-Completed.png"] forState:UIControlStateNormal];
[button setContentMode:UIViewContentModeScaleToFill];
[cell.contentView addSubview:button];
}
else {
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(11, 6, 21, 21);
button.tag = 1;
[button addTarget:self action:@selector(changeCompStatus:) forControlEvents:UIControlEventTouchUpInside];
[button setImage:[UIImage imageNamed:@"Comp-Uncompleted.png"] forState:UIControlStateNormal];
[button setContentMode:UIViewContentModeScaleToFill];
[cell.contentView addSubview:button];
}
Run Code Online (Sandbox Code Playgroud)
我试过添加:[button setEnabled:YES];,[button setHidden:NO];并且[button setNeedsDislpay];没有运气的过程.如何获得显示图像的按钮?
编辑: …
ios ×4
uibutton ×2
uiview ×2
cocoa ×1
cocoa-touch ×1
nscondition ×1
nsurlrequest ×1
objective-c ×1
uikit ×1
uiscrollview ×1
uitabbar ×1
uitableview ×1