小编Min*_*er3的帖子

将图像添加到UItableView

是否可以将图像添加到表格视图中?在左边?如果是这样,那应该是多大?

iphone cocoa-touch uitableview uikit

20
推荐指数
1
解决办法
4万
查看次数

将惯性添加到UIPanGestureRecognizer

我试图在屏幕上移动子视图,但我也希望为对象添加惯性或动量.
我已经拥有的UIPanGestureRecognizer代码如下.

提前致谢.

UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self       action:@selector(handlePan:)];
[self addGestureRecognizer:panGesture];

(void)handlePan:(UIPanGestureRecognizer *)recognizer
{

    CGPoint translation = [recognizer translationInView:self.superview];
    recognizer.view.center = CGPointMake(recognizer.view.center.x + translation.x,
                                     recognizer.view.center.y + translation.y);
    [recognizer setTranslation:CGPointMake(0, 0) inView:self.superview];

    if (recognizer.state == UIGestureRecognizerStateEnded) {
        [self.delegate card:self.tag movedTo:self.frame.origin];
    }
}
Run Code Online (Sandbox Code Playgroud)

再次谢谢.

momentum ios uipangesturerecognizer

12
推荐指数
1
解决办法
5322
查看次数

使用php编码json?

我想得到json与PHP编码功能如下

<?php 
  require "../classes/database.php";

  $database = new database();
  header("content-type: application/json");
  $result = $database->get_by_name($_POST['q']);   //$_POST['searchValue']

  echo '{"results":[';
  if($result)
  {
     $i = 1;
     while($row = mysql_fetch_array($result))
     {
        if(count($row) > 1) 
        {
           echo json_encode(array('id'=>$i, 'name' => $row['name']));
           echo ",";
        }
        else 
        {
           echo json_encode(array('id'=>$i, 'name' => $row['name']));
        }
        $i++; 
     }
  }
  else
  {
     $value = "FALSE";
     echo json_encode(array('id'=>1, 'name' => ""));  // output the json code
  }

  echo "]}";
Run Code Online (Sandbox Code Playgroud)

我希望输出json是这样的

{"results":[{"id":1,"name":"name1"},{"id":2,"name":"name2"}]}
Run Code Online (Sandbox Code Playgroud)

但输出json如下所示

{"results":[{"id":1,"name":"name1"},{"id":2,"name":"name2"},]}
Run Code Online (Sandbox Code Playgroud)

当你意识到最后有逗号时,我想删除它所以它可以是正确的json语法,如果我删除了echo ",";当有多个结果时json会生成这样的{"results":[{"id":1,"name":"name1"}{"id":2,"name":"name2"}]}并且语法也是错误的

希望每个人都明白我的意思,任何想法都会受到赞赏

php json

6
推荐指数
2
解决办法
3万
查看次数

筛选包含指定字符串的数组

我正在尝试开发一个包含大量单词数组的应用程序.我想从中创建一个新的过滤数组.过滤是基于我使用正则表达式创建的模式完成的.例如,我应该能够用我的数组中的模式"ap_l_"过滤出单词"apple".谁能帮我吗?

iphone objective-c filter ios

-1
推荐指数
1
解决办法
4028
查看次数