我正在将一个代码块从iOS4项目移植到iOS5,我遇到了一些ARC问题.该代码从屏幕截图生成PDF.
PDF生成代码
UIView *captureView;
...
NSMutableData *pdfData = [NSMutableData data];
UIGraphicsBeginPDFContextToData(pdfData, captureView.bounds, nil);
UIGraphicsBeginPDFPage();
CGContextRef pdfContext = UIGraphicsGetCurrentContext();
[captureView.layer renderInContext:pdfContext];
UIGraphicsEndPDFContext();Run Code Online (Sandbox Code Playgroud)
renderInContext行
[captureView.layer renderInContext:pdfContext];Run Code Online (Sandbox Code Playgroud)
生成以下错误.
Automatic Reference Counting issue
Receiver type 'CALayer' for instance message is a forward declarationRun Code Online (Sandbox Code Playgroud)
有什么想法在这里发生了什么?
core-animation objective-c calayer ios automatic-ref-counting
我有一个支持方向更改的iPad应用程序的嵌套视图层次结构.它看起来与以下类似.
UIViewController
UIView
- UIView
- UIImageView (disable rotation)
- UIImageView
- UIView (disable rotation)
- UIView
- UIView
...
Run Code Online (Sandbox Code Playgroud)
我想锁定一些子视图的方向,同时允许其他人自动旋转和调整大小.我似乎无法弄清楚如何实现这一目标.
一种方法似乎是手动旋转子视图willAnimateRotationToInterfaceOrientation:.鉴于SDK正在执行我将要撤消的轮换,这并不是特别有吸引力.
有没有办法简单地禁用子视图的方向更改或其他方法来重构我的层次结构?
我需要计算任意数量的数据点(超过1亿)的16位运算的均方误差.我决定使用平均值,所以我不必担心因添加大量平方错误而导致溢出.在1亿个样本中,我遇到浮点精度问题(结果不准确),所以我加倍了.
这是我的代码
int iDifference = getIdeal() - getValue();
m_iCycles++;
// calculate the running MSE as
// http://en.wikipedia.org/wiki/Moving_average
// MSE(i + 1) = MSE(i) + (E^2 - MSE(i))/(i + 1)
m_dMSE = m_dMSE + ((pow((double)iDifference,2) - m_dMSE) / (double)m_iCycles);
Run Code Online (Sandbox Code Playgroud)
有没有更好的方法来实现这一点来保持准确性?我考虑将MSE归一化为1并简单地在完成时保留最后一个除法的总和来计算平均值.
我正在使用一系列PNG图像作为精灵在平面上为Unity中的增强现实应用程序创建动画.PNG图像作为纹理加载,纹理应用于平面以创建跟踪增强现实目标的动画序列.
这是附加到平面并控制动画序列的脚本.
#pragma strict
var tecture : Texture[];
var changeInterval : float = 0.06;
var isRunning = false;
var isLooping = false;
function Start () {
var isRunning = true;
}
function Update () {
if( isRunning == true) {
Animation ();
}
}
function Animation () {
var index : int = Time.time/changeInterval;
index = index % tecture.Length;
renderer.material.mainTexture = tecture[index];
if ( index == tecture.Length-1){
if( isLooping == false){
isRunning = false;
}
renderer.material.mainTexture = tecture[0];
} …Run Code Online (Sandbox Code Playgroud) 我按照如何构建Apple推送通知提供程序服务器(教程)中的说明尝试设置推送通知服务器.
当我尝试连接以下PHP代码时
// connect to apns server
$strAPNSUrl = 'ssl://gateway.sandbox.push.apple.com:2195';
$strAPNSCert = 'dev.pem';
// generate stream
$oStreamContext = stream_context_create();
stream_context_set_option($oStreamContext, 'ssl', 'local_cert', $strAPNSCert);
// create the socket connection
$oAPNS = stream_socket_client($strAPNSUrl, $iError, $strError, 2, STREAM_CLIENT_CONNECT, $oStreamContext);
Run Code Online (Sandbox Code Playgroud)
我收到以下警告
Warning: stream_socket_client() [function.stream-socket-client]: SSL operation failed with code 1. OpenSSL Error messages: error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert
根据我在Google上找到的信息,问题似乎是我的证书.
我在OS X中生成我的csr和pem文件(按照教程中的说明使用pem文件).一旦我创建了dev.pem,我就将它上传到我的托管服务提供商并尝试运行我的php脚本.这是创建和"安装"证书的正确方法吗?
我已经没有调试想法了.任何方向都会很棒.
我有一个函数,我想在两个不同的自定义对象上操作.我的第一个想法是接受参数作为(id)并操作id对象.然而,我似乎无法弄清楚如何做到这一点.
这两个类(比如苹果和橙子)都有接口变量:
NSDecimalNumber *count;
Run Code Online (Sandbox Code Playgroud)
我想做类似的事情:
-(NSDecimalNumber*)addCount:(id)addObject{
return [count decimalNumberByAdding:addObject.count];
}
Run Code Online (Sandbox Code Playgroud)
我似乎无法弄清楚实现这一目标的语法.这是正确的方法,还是从子类(从水果类)开始并对父类进行操作会更好?
-(NSDecimalNumber*)addCount:(Fruit*)addFruit{
return [count decimalNumberByAdding:addFruit.count];
}
Run Code Online (Sandbox Code Playgroud) 我已经实现了一个充当过滤器的搜索框.当用户点击搜索区域时,会显示一个下拉框,显示所有可能的选项.在搜索框中键入会过滤结果.单击框外单击会隐藏结果.
它使用以下HTML/CSS heiarchy
<div class="search">
<input type="text" name="search" value="search" placeholder="search"/>
<div class="results">
<div class="result">
Result 1
</div>
<div class="result">
Result 2
</div>
...
</div>
</div>Run Code Online (Sandbox Code Playgroud)
我使用jQuery来显示/隐藏焦点/模糊事件的下拉列表
var searchBar = {
init : function(){
$('input[name=search]').focus(searchBar.openSearch);
$('input[name=search]').blur(searchBar.closeSearch);
$('div.result').each(function(e){
$(this).click(draftboardDynamic.selectResult);
});
},
openSearch : function(e){
$('div.results').show();
},
closeSearch : function(e){
$('div.results').hide();
},
selectResult : function(e){
console.log($(this));
},
}
$(document).ready(searchBar.init);Run Code Online (Sandbox Code Playgroud)
这非常有效,我可以打开,关闭和搜索(为清晰起见,JS已删除)没有问题.我遇到麻烦的唯一一点就是选择结果.模糊事件似乎在result.click事件之前触发,并且从不调用处理程序.我可以通过删除模糊绑定来纠正这个问题,但是,当输入失去焦点时,我无法弄清楚如何关闭我的下拉框.
有任何想法吗?
我想在带有爱丽丝蓝色背景的MainScreen上放置几个带有右对齐文本的LabelFields.不幸的是,我似乎无法弄清楚如何实现这一目标.
我能做的最好的事情是在MainScreen上将我的背景设置为Color.ALICEBLUE,并将LabelFields放在屏幕上(同样具有爱丽丝蓝色背景).
public void paint(Graphics graphics) {
graphics.setBackgroundColor(Color.ALICEBLUE);
graphics.clear();
super.paint(graphics);
}
Run Code Online (Sandbox Code Playgroud)
和...
LabelField display = new LabelField("", LabelField.FIELD_RIGHT){
public void paint(Graphics graphics) {
graphics.setColor(Color.DIMGRAY);
graphics.setBackgroundColor(Color.ALICEBLUE);
graphics.clear();
super.paint(graphics);
}
};
Run Code Online (Sandbox Code Playgroud)
覆盖MainScreen绘制例程给了我蓝色背景,但是覆盖LabelFields的绘图例程似乎不够.结果是一个白色的行,仅在标签文本后面带有爱丽丝蓝色背景.添加USE_ALL_WIDTH更正了背景问题,但我无法正确对齐USE_ALL_WIDTH.
有谁知道这方面的工作?
我正试图在Yii中进行全文搜索,我似乎无法找到问题.
我有以下SQL语句正常工作.
SELECT * FROM Topic WHERE MATCH(title,content) AGAINST ('testing' IN BOOLEAN MODE) LIMIT 11;
Run Code Online (Sandbox Code Playgroud)
在Yii,我正在使用似乎正在回归的以下评论 SELECT * FROM Topic LIMIT 11;
CDbcriteria Object
(
[_paramCount:private] => 0
[select] => *
[distinct] =>
[condition] =>
[params] => Array
(
)
[limit] => 11
[offset] => 0
[order] =>
[group] =>
[join] =>
[having] =>
[where] => Array
(
[0] => MATCH (title,content) AGAINST ('testing' IN BOOLEAN MODE)
)
)
Run Code Online (Sandbox Code Playgroud)
我出错的任何想法?
我正在努力将一些NSURLConnection代码转换为AFNetworking,我看到一个奇怪的问题,它无法识别我的本地MAMP.
这是我从NSURLConnection获得的错误消息
Error Domain=NSURLErrorDomain Code=-1004 "Could not connect to the server." UserInfo=0x160cb0 {NSErrorFailingURLStringKey=http://localhost:8888/webservices/poll.php, NSErrorFailingURLKey=http://localhost:8888/webservices/poll.php, NSLocalizedDescription=Could not connect to the server., NSUnderlyingError=0x15f910 "Could not connect to the server."}
NSURLConnection与MAMP玩得很好,我在使用AFNetworking连接到远程服务器时没有任何问题.此外,将失败的URL粘贴到我的浏览器中工作正常.
这是我正在使用的代码
AFHTTPClient *client = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:@"http://localhost:8888/webservices/"]];
[client getPath:@"poll.php"
parameters:nil
success:^(AFHTTPRequestOperation *operation, id response) {
NSString *text = [[NSString alloc] initWithData:response encoding:NSUTF8StringEncoding];
NSLog(@"Response: %@", text);
}
failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error");
NSLog(@"%@", error);
}];Run Code Online (Sandbox Code Playgroud)
我可以从远程服务器工作,但能够在本地进行更改而不必在每个编辑上传文件进行测试都会很好.我见过几个引用本地服务器的AFNetworking代码片段.任何想法可能在这里的问题?
ios ×3
objective-c ×2
afnetworking ×1
blackberry ×1
c++ ×1
calayer ×1
certificate ×1
html ×1
ipad ×1
javascript ×1
jquery ×1
macos ×1
mamp ×1
mysql ×1
onblur ×1
orientation ×1
php ×1
textures ×1
uiview ×1
yii ×1