我正在为iPhone制作聊天应用程序,但我不确定对话消息应该如何立即出现.
我已经阅读了关于此主题的大量Google搜索结果.也是曾经的:
- http://www.raywenderlich.com/3932/how-to-create-a-socket-based-iphone-app-and-server
- http://www.raywenderlich.com/3443/苹果推送通知服务教程部分-12
APNS方法:
将一个不可见的通知推送到iPhone,表示准备好读取新消息.因此,该应用程序将发出未读消息的请求.因此,我不会手动轮询新消息,而是让APNS帮忙.但我不确定?
套接字方法:
建立一个可以共享数据的套接字连接.在db中找到新消息时,它会自动将数据发送到应用程序.但是IP范围,防火墙,功耗等等呢?再次,我不确定:(
轮询方法:
制定一个我轮询请求的时间间隔,耗电量是我的敌人.
我的问题:
- 哪种方法最好?
- 其他建议?
- 我真的需要一些有这方面经验的人的利弊和专业人士.
例子总是好的.
谢谢
我已经花了很多时间来解决这个问题.我使用Restkit 0.9.3与Object Mapping 2.0.所有数据都是JSON.我可以正确地进行GET,POST,PUT和DELETE操作,它是我没有捕获的响应体并且正确地映射..
所以我的问题是,当出现问题时,我的restful api会返回错误.我想用restkit映射这些错误,fx返回此错误:
{"code":"401","message":"未经授权"}
如何映射这个json正确?我尝试了很多东西,可以使用一些指导 - 或者请举一个例子.
我已经下载了旋转轮控制项目.这是一个使用xib的XCode项目,我希望它能使用Storyboard.有没有一个很好的方法将xib"旋转轮控制"文件移动到故事板?
有没有人有将xib文件移动到Storyboard的经验?
我尽力做到最好,但是当我运行程序时,我得到了一个
NSInvalidArgumentException.
任何人都可以解释,我怎么能解决这个问题?
我无法找到解决问题的方法,所以我希望有些专家可以帮助我.
我有很多细胞的tableview.对于每个单元格,我有一个带圆角的图像视图:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UIImageView *exampleView;
...
exampleView.layer.cornerRadius = 5.f;
exampleView.clipsToBounds = YES;
[cell.contentView addSubview:exampleView];
...
}
Run Code Online (Sandbox Code Playgroud)
导致滚动性能问题严重不足 - 当使用cornerRadius和clipsToBounds = YES时,任何替代解决方案? (圆角图像视图包含图片,如果没有设置角落.滚动是平滑的.所以问题出在这里)
编辑#1:澄清我已阅读其他帖子:
...
exampleView.frame = CGRectMake(5.0f,size.height-15.0f,30.0f,30.0f);
exampleView.layer.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5].CGColor;
exampleView.layer.cornerRadius = 5.0f;
exampleView.layer.borderWidth = 0.3f;
exampleView.layer.borderColor = [UIColor blackColor].CGColor;
exampleView.layer.masksToBounds = NO;
exampleView.layer.shouldRasterize = YES;
//exampleView.clipsToBounds = NO;
[exampleView setImage: myImage ];
Run Code Online (Sandbox Code Playgroud)
编辑#2: 就像myImage正在研究圆角视图.如何使图像适合圆角视图?还是我错过了什么?
我想知道Trello iphone应用程序正在使用哪些库或框架.
它是一个使用JS框架的webapp吗?如果是的话,哪一个?
还是原生的?这个框架在这里?
我很好奇,因为我非常喜欢用户界面,并且在没有运气的情况下搜索了互联网.
我是 C# 编程的初学者。请帮我将 PHP 代码示例重写为 C#:
<?php
$final = array('header' => array(), 'data' => array());
$final['header'] = array('title' => 'Test', 'num' => 5, 'limit' => 5);
foreach ($results as $name => $data)
{
$final['data'][] = array('primary' =>'Primary','secondary' => 'Secondary','image' => 'test.png','onclick' => 'alert('You clicked on the Primary');');
}
header('Content-type: application/json');
echo json_encode(array($final));
?>
Run Code Online (Sandbox Code Playgroud)
我尝试过做类似的事情,但没有成功。
Dictionary<string, string> final = new Dictionary<string, string>();
stringArray.Add("header", "data");
Run Code Online (Sandbox Code Playgroud) <?php
require_once('app/config.php'); // Require constants HOST, DATABASE, USER, PASSWORD
/*
dbConnection class.
Manages connections to and operations on the database. Call dbConnection::getInstance() to return an instance.
Prepare your statements by calling prepareQuery() on the object
Attribute list:
$instance:
> Static self instance to manage database resource
$connection:
> Holds connection resource
$sth:
> Statement handler variable. Handles SQL statements.
_______________________________________________________________________________________________________________
Method list:
getInstance():
> Creates or returns existing connection to the database
prepareQuery():
> Prepares the $sth …Run Code Online (Sandbox Code Playgroud) 我有一个名为"buttonPressed"的按钮.当我按下按钮时,我需要找到该按钮的x和y坐标.你有什么想法可以帮助我吗?
UIButton *circleButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
circleButton.frame = rect;
circleButton.layer.cornerRadius = 8.0f;
[circleButton addTarget:self
action:@selector(buttonPressed:)
forControlEvents:UIControlEventTouchUpInside];
[self addSubview:circleButton];
-(void)buttonPressed:(id)sender
{
}
Run Code Online (Sandbox Code Playgroud)
回答
- (IBAction)buttonPressed:(UIButton *)sender
{
CGPoint coordinates = sender.frame.origin;
CGFloat x = coordinates.x;
CGFloat y = coordinates.y;
}
Run Code Online (Sandbox Code Playgroud) ios ×6
json ×2
php ×2
api ×1
arrays ×1
button ×1
c# ×1
chat ×1
coordinate ×1
dictionary ×1
frameworks ×1
iphone ×1
mysql ×1
native-code ×1
phpunit ×1
response ×1
restkit ×1
singleton ×1
sockets ×1
storyboard ×1
tags ×1
trello ×1
uibutton ×1
uitableview ×1
xcode ×1
xib ×1