直到iOS 3.2,我使用这种代码UIImageView在后台加载图像,它工作得很好......
码:
- (void)decodeImageName:(NSString *)name
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
UIImage *newImage = [UIImage imageNamed:name];
[myImageView setImage:newImage];
[pool release];
}
...
[self performSelectorInBackground:@selector(decodeImageName:) withObject:@"ID"]
Run Code Online (Sandbox Code Playgroud)
......即使[UIImageView setImage:]不是线程安全的!
但是从iOS 4开始,它不再起作用......图像在setImage通话两秒后出现在屏幕上.如果我做了一个[myImageView performSelectorOnMainThread:@selector(setImage:) withObject:newImage waitUntilDone:YES]而不是[myImageView setImage:newImage],图像立即显示,但似乎是在运行中再次重新解码(忽略之前[UIImage imageNamed:]应该已经解码图像数据),导致我的主线程暂停...即使文档说明底层图像缓存在所有线程之间共享..
任何想法 ?
我有一个使用Doctrine's Translatable extension的 Symfony 3.2 实体。
namespace AppBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* Media
*
* @ORM\Table(name="medias")
* @Gedmo\TranslationEntity(class="AppBundle\Entity\Translation\MediaTranslation")
*/
class Media implements Translatable
{
/* [...] */
/**
* @var string|null
*
* @ORM\Column(type="text", nullable=true)
* @Gedmo\Translatable
* @Groups({"single_media"})
*/
private $description;
/* [...] */
}
Run Code Online (Sandbox Code Playgroud)
我知道如何使用基本方法在 JSON 中序列化这个实体(我friendsofsymfony/rest-bundle用于 REST API 的序列化),但我想以这样的自定义方式序列化它......
{
"description": {
"fr": "description en français",
"en": "english description",
}
}
Run Code Online (Sandbox Code Playgroud) 当我的iPhone界面旋转时,我想为UIViewController的特定UIView做淡入/淡出......就像......
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.3];
theView.alpha = 0;
[UIView commitAnimations];
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.3];
theView.alpha = 1;
[UIView commitAnimations];
}
Run Code Online (Sandbox Code Playgroud)
但动画在旋转开始之前没有完成(我们可以看到视图开始自我调整大小)......
有没有办法延迟旋转开始?
"持续时间"是旋转动画的持续时间,对吧?
我在react-redux Provider上遇到问题:我将路由器从index.js中移到了routing.js文件中。我使用了提供程序来向我的路由组件提供有关商店的知识,但是在执行到达render方法之前,我得到了一个奇怪的警告:
Warning: Failed context type: The context `store.isRequired` is marked as required in `Routing`, but its value is `undefined`.
即使我摆脱.isRequiredin 也会发生这种情况Routing.contextTypes。而且,如果我在render函数的开头放置了一条调试器语句,那么它似乎this.context并不是未定义的,并且我的应用程序运行得很吸引人。我想知道我是否做错了什么,或者它可能是react-redux Provider的错误或什么。
这是我的代码:
index.js
import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { setLanguage } from 'redux-i18n';
import I18n from 'redux-i18n/immutable';
import configureStore from './store/configure_store';
import { Routing } from './routing';
import translations from './translations';
import '../scss/index.scss';
const store = configureStore();
store.dispatch(setLanguage(navigator.language));
ReactDOM.render(
<Provider store={ store …Run Code Online (Sandbox Code Playgroud) 我们使用Xcode 5.1开发了一个仅限iPhone的应用程序(不是Universal),在iPad上运行时," 2x "按钮丢失,应用程序以" 2x "模式启动.怎么会发生这种情况?我想当你在iPad上运行iPhone应用程序时,总会有" 2x "按钮......
编辑:我们在iOS 7下对真正的非视网膜iPad Mini进行测试.
iphone ×2
animation ×1
doctrine-orm ×1
ios ×1
ios4 ×1
javascript ×1
react-redux ×1
reactjs ×1
redux ×1
rotation ×1
symfony ×1
symfony-3.2 ×1
uiimage ×1