我有一个自定义的UITableViewCell,它由以下内容初始化:
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
NSArray *nibArray = [[NSBundle mainBundle] loadNibNamed:@"CustomCell" owner:self options:nil];
self = [nibArray objectAtIndex:0];
[self setSelectionStyle:UITableViewCellSelectionStyleNone];
[self.downButton setBackgroundImage:[UIImage imageNamed:@"button"] forState:UIControlStateNormal];
[self.downButton setBackgroundImage:[UIImage imageNamed:@"buttonSelected"] forState:UIControlStateHighlighted];
}
return self;
}
Run Code Online (Sandbox Code Playgroud)
按钮显示正确,带有适当的背景图像,但按下/单击按钮时,突出显示的图像不会立即显示.相反,您必须在更改发生之前将其保持一两秒钟.另一方面,释放按钮确实可以立即更改回原始背景图像.
在切换到突出显示的图像时尝试缓解迟到的变化,我将更改放在以下方法中:
- (IBAction)downDown:(id)sender {
[self.downButton setBackgroundColor:[UIColor redColor]];
}
Run Code Online (Sandbox Code Playgroud)
上面的方法设置为"Touch Down"(与更常见的"Touch Up Inside"相对),我已经删除setBackgroundImage:forState:了突出显示的状态.与上述相同的问题.颜色最终会变为红色,但只有在单击并按住按钮一两秒后才会变亮.
我有一个按钮的方法,当"Touch Up Inside"出现时,该方法会执行,并且该方法可以毫无问题地执行 - 无论我是否快速点击按钮,或者在释放之前单击并按住它一段时间.
那么为什么延迟"触地"还是UIControlStateHighlighted?我正在尝试向用户提供即时反馈,以显示按钮已被按下.
如果需要,我可以提供更多代码,但这些是与背景外观有关的唯一位.
在CSS中使用transform属性时,可能的方法之一是matrix需要6个输入字段的方法.CSS代码看起来像......
#test{
transform: matrix(1, 0, 0, 1, 0, 0);
}
Run Code Online (Sandbox Code Playgroud)
还有其他几种变体(取决于浏览器)......
-ms-transform: matrix(1, 0, 0, 1, 0, 0);
-webkit-transform: matrix(1, 0, 0, 1, 0, 0);
Run Code Online (Sandbox Code Playgroud)
我知道上面显示的值是对象的库存值,但所有数字的含义是什么?
关于消失的iFrame内容有很多帖子,但我能找到的内容是关于立即消失或随机消失的内容.
我的情况有点不同.
我有iframe一个父div:
<div id="punt" contentid="123">
<iframe id="content_frame" sandbox="allow-forms allow-popups allow-scripts allow-same-origin" src="" ></iframe>
</div>
Run Code Online (Sandbox Code Playgroud)
当iframe完全填满其母公司,这本身就是近视区的全尺寸.
iframe通过JS/JQuery设置的内容:
function loadURL(url){
$('#content_frame').attr('src', url);
}
Run Code Online (Sandbox Code Playgroud)
另外,eventListeners受到约束iframe
$("#content_frame").on("load", function () {
if(isNewURL){
bindAndFocus();
}
});
Run Code Online (Sandbox Code Playgroud)
哪里
function bindAndFocus(){
$('#content_frame').bind({
mouseenter: function(e) {
overiFrame = $(this).parent().attr('contentid');
},
mouseleave: function(e) {
overiFrame = -1;
}
});
}
Run Code Online (Sandbox Code Playgroud)
清除内容后,将关闭侦听器:
$('#content_frame').unbind('mouseenter mouseleave');
Run Code Online (Sandbox Code Playgroud)
这一切都很棒.URL加载正常,内容可滚动并且可以与在浏览器中直接查看一样进行交互.听众是一个黑客共同的尝试(来自另一个SO帖子),以确定何时iframe与之交互 - 一点点击中和未命中,但不是手头的问题.
但是之后...
神秘的消失法案!?
当您将URL加载到iframe,然后在其他选项卡中播放一段时间(在同一浏览器中)时,会出现此问题.消失不是即时的 - 在几个标签之间快速切换然后返回没有效果.但是当你在不同的标签中花费一些时间(几分钟或更长时间),然后返回时,内容就会 …
我有三张桌子,比如:
*table1*
id | val1 | val2 | val3 | val4 | val5
1 | ... | ... | ... | ... | ...
2 | ... | ... | ... | ... | ...
3 | ... | ... | ... | ... | ...
... etc
Run Code Online (Sandbox Code Playgroud)
和
*table2*
id | som1 | som2
1 | ... | ...
2 | ... | ...
3 | ... | ...
... etc
Run Code Online (Sandbox Code Playgroud)
和
*table3*
id | col1 | col2
1 …Run Code Online (Sandbox Code Playgroud) 注意:附加信息作为编辑#1附加到原始问题的末尾,详细说明request-promise后端如何导致UI冻结.请记住,纯CSS动画暂时挂起,你可能只是跳到编辑(或完全阅读全部)
设置
我正在使用Electron开发桌面webapp .
有一次,用户需要输入并提交一些数据.当他们点击"提交"时,我使用JS来显示这个css加载动画(右下角加载器),并将数据异步发送到后端...
- HTML -
<button id="submitBtn" type="submit" disabled="true">Go!</button>
<div class="submit-loader">
<div class="loader _hide"></div>
</div>
Run Code Online (Sandbox Code Playgroud)
- JS -
form.addEventListener('submit', function(e) {
e.preventDefault();
loader.classList.remove('_hide');
setTimeout(function() {
ipcRenderer.send('credentials:submit', credentials);
}, 0)
});
Run Code Online (Sandbox Code Playgroud)
在哪里._hide简单
._hide {
visibility: hidden;
}
Run Code Online (Sandbox Code Playgroud)
并且其中ipcRenderer.send()是一个异步方法,而不选项的设置,否则.
问题
通常,0ms延迟足以允许在阻塞事件发生之前更改DOM.但不是在这里.无论是否使用setTimeout(),仍有延迟.
所以,加上一点延迟......
loader.classList.remove('_hide');
setTimeout(function() {
ipcRenderer.send('credentials:submit', credentials);
}, 100);
Run Code Online (Sandbox Code Playgroud)
大!装载机在提交后立即显示!但是...在100ms之后,动画在其轨道上停止了大约500ms左右,然后又回到了chooching.
无论延迟长度如何,这种工作 - >不工作 - >工作模式都会发生.一旦ipcRenderer开始做东西,一切都停止了.
所以为什么!?
这是我第一次看到这种行为.我非常精通HTML/CSS/JS,但我不熟悉NodeJS和Electron.为什么我的纯CSS …
在视图#1中,我在故事板中设置了两个控件; 一个是导航栏中的UIBarButtonItem,另一个是UISegmentedController.前者是自定义绘制的图像,两个项目的色调都设置为紫色(故事板属性检查器中设置的色调).
通过各种动作,用户可以通过视图#1进入视图#2.如果在View#2中未满足某个条件,则会向用户显示错误消息,并在单击"确定"后重定向回View#1.
if(i == [self.itemsAvailable count]){
UIAlertView *alertView = [[UIAlertView alloc]
initWithTitle:@"Oh no!"
message:@"Warning message text!"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil, nil];
[alertView show];
break;
}
Run Code Online (Sandbox Code Playgroud)
请注意,警报是在while循环内触发的,因此break;.然后,以下函数返回到View#1
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == [alertView cancelButtonIndex]) {
// Jump back one screen
[self.navigationController popViewControllerAnimated:YES];
}
}
Run Code Online (Sandbox Code Playgroud)
问题是,当我使用该函数返回View#1时popViewControllerAnimated:YES,前面提到的两个控件(UIBarButtonItem和UISegmentedController)的色调显示为灰色而不是所需的紫色.
选择不同的UISegmentedController值带回合适的色调的颜色,但我需要离开查看#1对的UIBarButtonItem …
我按照这个开发人员教程,按照预期在我的应用程序中运行Geofencing.
发生地理围栏转换时会发出通知,来自IntentService:
@Override
protected void onHandleIntent(Intent intent) {
GeofencingEvent geofencingEvent = GeofencingEvent.fromIntent(intent);
...
sendNotification(geofenceTransitionDetails);
}
private void sendNotification(String notificationDetails) {
// Create an explicit content Intent that starts the main Activity.
Intent notificationIntent = new Intent(getApplicationContext(), MainActivity.class);
// Construct a task stack.
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
// Add the main Activity to the task stack as the parent.
stackBuilder.addParentStack(MainActivity.class);
// Push the content Intent onto the stack.
stackBuilder.addNextIntent(notificationIntent);
// Get a PendingIntent containing the entire back …Run Code Online (Sandbox Code Playgroud) android android-notifications intentservice android-alertdialog android-geofence
我对SSE来说是全新的.服务器发送事件有很多简单/介绍性文本
但他们都没有涉及为多个不同的用户使用相同的SSE文件.
例如:
我有一个用户登录的站点.登录后,他们可以查看对他们来说唯一且私有的数据.我希望每个用户在登录时都有实时更新,这些更新可能包含也可能不包含敏感信息.为此,我正在实现服务器发送的事件:
JS(直接从其中一个链接)
var source;
if (!!window.EventSource) {
source = new EventSource("sse.php");
} else {
...
}
source.addEventListener("message", function(e) {
... do stuff ...
}, false);
Run Code Online (Sandbox Code Playgroud)
PHP
header("Content-Type: text/event-stream");
header("Cache-Control: no-cache");
header("Connection: keep-alive");
while (true) {
$data = \\ query DB or any other source
if ($data) {
sendMessage($someID, $data);
}
sleep(2);
}
function sendMessage($id, $data) {
echo "id: $id\n";
echo "data: $data\n\n";
ob_flush();
flush();
}
Run Code Online (Sandbox Code Playgroud)
但是这样使用它,我只是将数据发送给打开sse.php源的用户(即每个EventSource("sse.php")都是一个新的,唯一的连接)?或者每个人都登录,谁初始化了连接,收到相同的数据?
这个SO答案通过使用独特的事件触及多个用户:
echo "event: …Run Code Online (Sandbox Code Playgroud) 我正在尝试通过增加执行成功查询的机会来改善用户体验。
有问题的查询是简单、快速的操作——例如:
$stmt = $db->prepare('SELECT val1, val2, val3 FROM table WHERE id=?');
$stmt->execute(array($someID));
...
Run Code Online (Sandbox Code Playgroud)
或者
$stmt = $db->prepare('INSERT INTO table (val1, val2, val3) VALUES (?, ?, ?)');
$stmt->execute(array($val1, $val2, $val3));
Run Code Online (Sandbox Code Playgroud)
等等。没有连接,没有大量的数据。查询需要几分之一秒。
因为它们非常快,所以我认为多次循环同一个查询是合适和安全的,如果它失败了。
就像是:
function test($someVal, $db){
$db->beginTransaction();
try{
$stmt = $db->prepare('SELECT val1, val2, val3 FROM table WHERE id=?');
$stmt->execute(array($someVal));
$result = $stmt->fetchAll();
$db->commit();
if(count($result)){
$arr = array();
$arr['val1'] = $result[0]['val1'];
$arr['val2'] = $result[0]['val2'];
$arr['val3'] = $result[0]['val3'];
}else{
return 'empty';
}
return $arr; // All went well!
}catch(Exception $e){
$db->rollBack();
// …Run Code Online (Sandbox Code Playgroud) 设置
查看BrowserWindow Events Docs,该close事件是......
当窗口将要关闭时发出
事件closed是...
当窗口关闭时发出。
问题
当我手动关闭窗口(即单击菜单栏中的“x”)以及以编程方式关闭窗口(即window.close())时,这两个事件都会被触发;
该窗口需要不同的处理,具体取决于我是以编程方式关闭窗口还是手动关闭它(如果使用“x”,则完全退出应用程序,或者以其他方式执行一些操作)。
那么,我该如何...
我如何区分两者?
javascript ×4
php ×3
css ×2
electron ×2
html ×2
ios ×2
mysql ×2
node.js ×2
objective-c ×2
android ×1
iframe ×1
join ×1
jquery ×1
pdo ×1
transform ×1
uibutton ×1
uistoryboard ×1
uitableview ×1