我刚刚在我的项目中添加了一个Watch应用程序并尝试:
override func awakeWithContext(context: AnyObject?) {
super.awakeWithContext(context)
let res = WKInterfaceController.openParentApplication(["key" : "value"]) { (replyInfo, error) -> Void in
print("replyInfo : \(replyInfo) + error \(error)")
}
print(res) // true here
}
Run Code Online (Sandbox Code Playgroud)
在我的AppDelegate中,我写道:
func application(application: UIApplication, handleWatchKitExtensionRequest userInfo: [NSObject : AnyObject]?, reply: ([NSObject : AnyObject]?) -> Void) {
reply(["replyKey" : "replyValue"]);
}
Run Code Online (Sandbox Code Playgroud)
当我启动Watch应用程序时,我只有:
replyInfo:[:] + error可选(错误域= FBSOpenApplicationErrorDomain Code = 3"操作无法完成.(FBSOpenApplicationErrorDomain eor 3.)")
是由于模拟器?你知道做错了什么吗?
谢谢 !
我试图将像"12000.54"这样的NSString转换为"12.000,54".我写了一个NSNumberFormatter实例.
NSNumberFormatter *formatter = [[[NSNumberFormatter alloc] init] autorelease];
[formatter setFormatterBehavior:NSNumberFormatterBehavior10_4];
[formatter setNumberStyle:NSNumberFormatterDecimalStyle];
[formatter setGroupingSeparator:@"."];
[formatter setDecimalSeparator:@","];
Run Code Online (Sandbox Code Playgroud)
但当我NSLog这个时:
NSLog(@"%@",[formatter stringFromNumber:[formatter numberFromString:value]]);
Run Code Online (Sandbox Code Playgroud)
它打印空值.如果我用一个点改变我的逗号它正常工作.我只是希望能够把我想要的东西放在我的分隔符字段(逗号,点,斜线等等)中,并且我有不同的输出:例如12/000,54 12.000.54 12,000,54.
你知道我怎么处理这个吗?
我对Apple iPhone Contact App有一些疑问.我想使用相同的方法来创建和修改信息.
这是两个图片:
alt text http://grab.by/4ZjQ alt text http://grab.by/4ZjR
所以我们有创作和版本.该表单看起来像一个带有groupsStyle的UITableView,但我不知道如何重新创建所有这些.您是否有想法或教程可以解释如何做到这一点?
非常感谢 !
在我的应用程序中,我使用的是截图方法.在我的iPad 2上执行此方法的速度非常快(约130毫秒).但是在新的iPad上(当然由于最高的分辨率和相同的CPU),它需要700毫秒!有没有办法优化我的方法?也许有办法直接使用显卡吗?
这是我的截图方法:
- (UIImage *)image {
CGSize imageSize = self.bounds.size;
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) UIGraphicsBeginImageContextWithOptions(imageSize, NO, [UIScreen mainScreen].scale);
else UIGraphicsBeginImageContext(imageSize);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSaveGState(context);
CGContextTranslateCTM(context, [self center].x, [self center].y);
CGContextConcatCTM(context, [self transform]);
CGContextTranslateCTM(context, -[self bounds].size.width * [[self layer] anchorPoint].x, -[self bounds].size.height * [[self layer] anchorPoint].y);
[[self layer] renderInContext:context];
CGContextRestoreGState(context);
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
Run Code Online (Sandbox Code Playgroud)
}
谢谢你的帮助.
有没有办法在PHP中使用cURL(而不是stream_socket_client)实现发布推送通知系统?
我写 :
$url = 'https://gateway.sandbox.push.apple.com:2195';
$cert = 'AppCert.pem';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_SSLCERT, $cert);
curl_setopt($ch, CURLOPT_SSLCERTPASSWD, "passphrase");
$curl_scraped_page = curl_exec($ch);
Run Code Online (Sandbox Code Playgroud)
但是如何设置设备令牌和json消息?
我正在UIImage用这段代码制作一个视图
CABasicAnimation *animation;
animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
animation.duration = 1;
animation.toValue = [NSNumber numberWithFloat:M_PI];
animation.fromValue = [NSNumber numberWithInt:0];
[square.layer addAnimation:animation forKey:@"rotation"];
Run Code Online (Sandbox Code Playgroud)
一切正常但我的阵列在动画结束时占据了原来的位置.我查看了图层属性,发现:
[square.layer setTransform:CATransform3DRotate(HERE, -M_PI, 0, 0, 0)];
Run Code Online (Sandbox Code Playgroud)
我不知道写什么而不是"HERE".请问你能帮帮我吗?非常感谢 !
我必须向iOS设备发送推送通知.我的连接必须通过代理启用.我尝试了一切但没有成功.我有一个错误110连接超时.如果我只是尝试连接Apple推送地址,它正在使用cURL.我不知道问题出在哪里.代理配置?PHP stream_context错误的实现?
这是我的代码:
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', 'certificate.pem');
stream_context_set_option($ctx, 'ssl', 'passphrase', 'my_passphrase');
stream_context_set_option($ctx, 'ssl', 'verify_peer', false);
stream_context_set_option($ctx, 'http', 'proxy', 'tcp://my-proxy.net:8080');
stream_context_set_option($ctx, 'http', 'request_fulluri', true);
$fp = stream_socket_client('ssl://gateway.sandbox.push.apple.com:2195', $err,$errstr, 60, STREAM_CLIENT_CONNECT, $ctx);
var_dump($fp);
var_dump($err);
var_dump($errstr);
exit;
Run Code Online (Sandbox Code Playgroud)
你有好主意吗 ?
编辑:
它可以直接链接到Squid吗?我刚刚发现代理正在运行Squid.我也尝试使用fopen()函数而不是stream_socket_client()它似乎不允许ssl协议.
这是我的var_dump输出:bool(false)int(110)string(20)"连接超时"
我也有这个警告:警告:stream_socket_client():无法连接到第22行/share/www/website/test.php中的ssl://gateway.sandbox.push.apple.com:2195(连接超时)
我有一个动画,当手势识别器(双击)触发时,它会被踢掉:
[UIView animateWithDuration:0.3 animations:^{
_scrollView.contentOffset = CGPointMake(x, y);
_scrollViewContentView.frame = someFrame;
_scrollViewContentView.layer.transform =
CATransform3DMakeScale(1.f/_zoomScale, 1.f/_zoomScale, 1.f);
}];
Run Code Online (Sandbox Code Playgroud)
除了一种情况之外它工作得很好:如果scrollViewWillBeginDecelerating在动画执行之前没有调用委托方法(只是拖动几乎我的scrollview).
我只是有scrollViewDidEndDragging方法叫.我可以等20秒,然后播放我的动画.它会正常播放,除了我的contentOffset.
委托方法本身什么都不做,只是添加它们才能看出问题所在.
我不知道为什么.
编辑:这是我的问题视频.第1阶段:减速滚动,第2阶段没有.看看最后的位置.阶段1是正确的但不是阶段
objective-c uiscrollview ios contentoffset animatewithduration
我想,我的问题有点简单,但看不到如何实现这一目标.
我想要一个横向UICollectionView,我可以看到我的上一个和下一个单元格.
我已经设置了水平,分页启用collectionView及其流程布局.
我"只是"想念这件事.
这是我想要的模型.

我的问题是:我无法得到这个位置:当前单元格居中,前一个和下一个出现.我没有成功地使用我的布局- minimumInteritemSpacing和- sectionInset属性.
我正在使用 SwiftUI 并想抽象一个@EnvironmentObject. 目标是从生产切换BindableObject到假的(测试/本地工作......)
首先,我刚刚声明了一个协议:
protocol FetcherInterface: BindableObject {
associatedtype T
var didChange: PassthroughSubject<[T], Never> { get set }
var values: [T] { get set }
}
Run Code Online (Sandbox Code Playgroud)
然后我可以编写一个符合以下条件的网络根类FetcherInterface:
open class NetworkFetcher<T: Decodable>: FetcherInterface {
public var didChange = PassthroughSubject<[T], Never>()
internal var values: [T] = [T]() {
didSet {
DispatchQueue.main.async {
dump("did set network values \(self.values)")
self.didChange.send(self.values)
}
}
}
internal func loadAsync(values: [T]) {
DispatchQueue.global().asyncAfter(deadline: .now() + 1) {
self.values = values
} …Run Code Online (Sandbox Code Playgroud) ios ×6
objective-c ×4
iphone ×2
php ×2
apple-watch ×1
contact ×1
curl ×1
decimal ×1
http-proxy ×1
ipad ×1
push ×1
screenshot ×1
separator ×1
swift ×1
swiftui ×1
uiscrollview ×1
uitableview ×1
watchkit ×1