我有一个UIImageView
内部UIScrollView
自动缩小以适应所提供的图像.用户可以像往常一样使用捏合手势进行缩放,并且平移手势被设置为需要两次触摸,因为绘图优先.
在发布时,一切看起来都很棒,但是当我调用我的绘图代码时,会发生以下情况:
如您所见,在drawLineFrom(fromPoint:toPoint:)
调用时,UIImageView
收缩.之后,图形似乎按预期工作(尽管它在每次触摸时都会跳过线条的第一部分).
我的UIPanGestureRecognizer
选择器:
@objc func onOneFingerDrawing(_ sender: UIPanGestureRecognizer) {
switch sender.state {
case .began:
swiped = false
lastPoint = sender.location(in: drawView.imageView)
case .changed:
swiped = true
let currentPoint = sender.location(in: drawView.imageView)
drawLineFrom(fromPoint: lastPoint, toPoint: currentPoint)
lastPoint = currentPoint
case .ended:
guard drawView.scrollView.frame.contains(sender.location(in: drawView.imageView)) else {
return
}
if let newImage = drawView.imageView.image {
if history.count > historyIndex + 1 {
history.removeLast((history.count - 1) - historyIndex)
}
history.append(newImage)
historyIndex = …
Run Code Online (Sandbox Code Playgroud) 我已向Apple提交了有关此问题的错误报告!
我正在尝试在我的UITableViewHeader上使用新的iOS 6 Auto Layout,但是我抛出的所有东西都会在帖子结尾处返回错误.
我的代码:
TBMTableViewController.h
#import <UIKit/UIKit.h>
@interface TBMTableViewController : UIViewController <UITableViewDataSource, UITableViewDelegate>
@end
Run Code Online (Sandbox Code Playgroud)
TBMTableViewController.m
#import "TBMTableViewController.h"
#import "UIView+Constraint.h"
@implementation TBMTableViewController
- (void)viewDidLoad
{
[super viewDidLoad];
UITableViewController *tableViewController = [[UITableViewController alloc] initWithStyle:UITableViewStylePlain];
[tableViewController.tableView setTranslatesAutoresizingMaskIntoConstraints:NO];
UITableView *tableView = tableViewController.tableView;
[tableView setTranslatesAutoresizingMaskIntoConstraints:NO];
[tableView setDelegate:self];
[tableView setDataSource:self];
[self.view addSubview:tableView];
UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 200.0f)];
[headerView setTranslatesAutoresizingMaskIntoConstraints:NO];
[tableView setTableHeaderView:headerView];
UIButton *btn1 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[btn1 setTranslatesAutoresizingMaskIntoConstraints:NO];
[btn1 setTitle:@"Button 1" forState:UIControlStateNormal];
[btn1 sizeToFit];
[headerView addSubview:btn1];
UIButton *btn2 = [UIButton …
Run Code Online (Sandbox Code Playgroud) 我正在尝试设置我的网站,以便通过javascript加载主区域中的内容(某些页面需要一段时间才能呈现).但是,在使用jQuery.load(),jQuery.getScript和jQuery.ajax()时,我遇到了一些逻辑问题.
我需要能够通过getScript加载某些javascript文件,以便我可以在加载的内容中使用这些函数等.
的script.js:
$(document).ready(function() {
$('#loading').fadeIn('fast');
$('#maincontent').load('load.php', function() {
$('#loading').fadeOut('fast');
$('#maincontent').fadeIn('slow');
});
$('#navigation li a').click(function() {
$('#maincontent').fadeOut('fast');
$.getScript('js/jquery.contextMenu-1.01.js');
$.getScript('js/jquery-1.5.1.min.js');
$.getScript('js/jquery-ui-1.8.12.custom.min.js');
$.getScript('js/jquery.qtip-2.0.0.min.js');
$.getScript('js/ajax.js');
$.ajax({
method: 'get',
url: 'load.php',
data: 'page=' + $(this).attr('rel'),
beforeSend: function() {
$('#loading').fadeIn('fast');
},
complete: function() {
$('#loading').fadeOut('fast');
},
success: function(html) {
$('#maincontent').fadeIn('slow');
$('#maincontent').html(html);
}
});
});
$.getScript('js/jquery.contextMenu-1.01.js');
$.getScript('js/jquery-1.5.1.min.js');
$.getScript('js/jquery-ui-1.8.12.custom.min.js');
$.getScript('js/jquery.qtip-2.0.0.min.js');
$.getScript('js/ajax.js');
});
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,我正在尝试首先加载load.php而不使用任何URL参数和来自用户的任何交互.尽管每次都正确加载load.php,但javascript代码却无法说明.有时它可以工作,有时我必须刷新页面几次才能得到一个干净的控制台(没有错误).
控制台中的错误告诉我,在load.php中使用js代码之前,它没有正确加载.如果load.php需要一段时间(使用PHP sleep(5)函数测试),则尤其如此.
如果我需要澄清任何事情,请告诉我:)
ios ×2
ajax ×1
autolayout ×1
drawing ×1
getscript ×1
jquery ×1
load ×1
objective-c ×1
swift ×1
uitableview ×1