小编Mar*_*rkP的帖子

Swift:将UITableViewCell标签传递给新的ViewController

我有一个UITableView,它使用基于JSON调用的数据填充Cell.像这样:

var items = ["Loading..."]
var indexValue = 0

// Here is SwiftyJSON code //

for (index, item) in enumerate(json) {
    var indvItem = json[index]["Brand"]["Name"].stringValue
    self.items.insert(indvItem, atIndex: indexValue)
    indexValue++
}
self.tableView.reloadData()
Run Code Online (Sandbox Code Playgroud)

如何在选中单元格时获取单元格的标签,然后将其传递给另一个ViewController?

我设法得到:

func tableView(tableView: UITableView!, didSelectRowAtIndexPath indexPath: NSIndexPath!) {
    println("You selected cell #\(indexPath.row)!")

    // Get Cell Label
    let indexPath = tableView.indexPathForSelectedRow();
    let currentCell = tableView.cellForRowAtIndexPath(indexPath!) as UITableViewCell!;

    println(currentCell.textLabel.text)
}
Run Code Online (Sandbox Code Playgroud)

我只是想弄清楚如何将它作为变量传递给下一个UIViewController.

谢谢

uitableview uiviewcontroller segue swift

19
推荐指数
2
解决办法
4万
查看次数

垂直堆叠的Google Bar Charts

我正在尝试使用Google Charts API生成垂直堆叠的条形图,我认为当找到该选项时我找到了解决方案:

isStacked: true
Run Code Online (Sandbox Code Playgroud)

但是,这似乎是水平添加堆叠(见下面的链接),我似乎无法找到一种方法来做到这一点.有人之前遇到过这个或者可以帮助我吗?

见:http://jsfiddle.net/tmA55/1/

谢谢

google-visualization bar-chart stacked-chart

11
推荐指数
1
解决办法
2万
查看次数

CKeditor的实例已经存在

我已经在Stack溢出上发现了一些类似的帖子,但没有一个有效的答案.

我在页面上有几个标签,根据他们点击的标签,他们会看到一个特定的标签.在其中一个标签中有一个CKeditor,它是在点击li时启动的.当用户将该特定选项卡单击到另一个选项卡上,然后返回时会出现以下错误:

未捕获编辑器实例"employDesc"已附加到提供的元素.

这是JS:

    $('.addVacancy').click( function() {
        if(CKEDITOR.instances.employDesc)  {
            alert('instance exists');
            var editor = CKEDITOR.instances[employDesc];
            if (editor) { 
                editor.destroy(true); 
            } 
            alert('distroyed');
        }   
        CKEDITOR.replace('employDesc');
    });
Run Code Online (Sandbox Code Playgroud)

两个警报都会出现,但随着控制台中出现错误而中断.有人能帮忙吗?

谢谢

jquery ckeditor

8
推荐指数
1
解决办法
2万
查看次数

动态生成UITableView单元和头部

项目文件:

https://jumpshare.com/v/Otai3BBXYwfvyz8jb53k

(明智地看这些看项目的结构)

问题:

好的,所以我正在按照教程创建一个带标题的UITableView,然后是单元格内容.

代码运行良好,运行良好,现在我想扩展到该教程之外,并使用alamofire和SwiftyJSON动态加载该内容.

在本教程中,使用的代码如下:

func getSectionsFromData() -> [Sections] {

    var sectionsArray = [Sections]()

    let animals = Sections(title: "Animals", objects: ["Cats", "Dogs", "Birds", "Lions"])


    sectionsArray.append(animals)

    return sectionsArray


}
Run Code Online (Sandbox Code Playgroud)

我试图做的是:

Alamofire.request(.GET, url).validate().responseJSON { response in
        switch response.result {
        case .Success:
            if let value = response.result.value {
                let json = JSON(value)

                for (_, subJson) in json {
                    for (year, content) in subJson {
                        let title = year
                        let objects = content

                        sectionsArray.append(Sections(title: title, objects: objects))

                    }

                }
            } …
Run Code Online (Sandbox Code Playgroud)

json uitableview swift alamofire swifty-json

7
推荐指数
1
解决办法
420
查看次数

在WP循环中为最后一项添加额外的类

我正在使用它来根据评论推出四个最受欢迎的帖子:

        <?php
            $pc = new WP_Query('orderby=comment_count&posts_per_page=4'); ?>
            <?php while ($pc->have_posts()) : $pc->the_post(); ?>
            <div class="popular-post-item">
            <span class="popular-title"><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" class="post-links"><?php the_title(); ?></a></span>
            <span class="popular-author">by: <?php the_author() ?></span> 
            <a href="<?php the_permalink(); ?>" class="action">Read Full Article</a>
            </div>
        <?php endwhile; ?> 
Run Code Online (Sandbox Code Playgroud)

我需要的是第四个:

        <div class="popular-post-item"> 
Run Code Online (Sandbox Code Playgroud)

添加另一个名为.last的类

有任何想法吗?

php wordpress

3
推荐指数
1
解决办法
5280
查看次数

Google AreaChart不显示垂直网格线.

首先,我检查了这些:

而且他们似乎并不是我正在寻找的东西,所以希望这不是一个重复的问题.

我在将网格线添加到Google AreaChart垂直轴时遇到问题.我用过:

 vAxis: {
        minValue: 0,
        gridlines: {
            color: '#f3f3f3',
            count: 5
        }
    }
Run Code Online (Sandbox Code Playgroud)

但它似乎没有工作,当我更改vAxis计数的值:它添加行到hAxis :(

见:http://jsfiddle.net/j29Pt/2/

谁能解决这个问题?

提前致谢 :)

javascript google-visualization

2
推荐指数
1
解决办法
7683
查看次数

使这个UITableviewCell可点击

我目前正在完成本教程.http://thedarkdev.blogspot.co.uk/2013/09/web-service-apps-in-ios7-json-with.html.我已经完成了,一切正常.

我想要的是:你能告诉我如何使整个单元格可点击 - 网址应该是JSON提要中指定的网址.

这是.h:

#import "ViewController.h"

@interface ViewController ()
{
NSMutableArray *myObject;
// A dictionary object
NSDictionary *dictionary;
// Define keys
NSString *title;
NSString *thumbnail;
NSString *author;
NSString *permalink;
}
@end

@implementation ViewController

- (void)viewDidLoad
{
[super viewDidLoad];
title = @"title";
thumbnail = @"thumbnail";
author = @"author";
permalink = @"permalink";

myObject = [[NSMutableArray alloc] init];

NSData *jsonSource = [NSData dataWithContentsOfURL:
                      [NSURL URLWithString:@"http://ios-blog.co.uk/?feed=json"]];

id jsonObjects = [NSJSONSerialization JSONObjectWithData:
                  jsonSource options:NSJSONReadingMutableContainers error:nil];

for (NSDictionary *dataDict in jsonObjects) {
    NSString …
Run Code Online (Sandbox Code Playgroud)

objective-c uitableview clickable

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

WordPress publish_post挂钩不为自定义帖子类型触发

我目前正在使用WP Job Board Manager插件做一些工作,我想创建一个在发布新作业时触发的功能.

我做的第一件事是创建一般钩子来找出帖子类型是什么:

function newJobAdded() {
    $posttype = get_post_type( $post );
    mail('email@email.com','new job published',$posttype);


 }
add_action( 'publish_post', 'newJobAdded' );
Run Code Online (Sandbox Code Playgroud)

这给我发了一封电子邮件告诉我帖子类型是:job_listing.然后我创建了一个新函数,只有在自定义帖子类型为job_listing时才会触发

function newJobAdded() {

   $posttype = "job_listing";

   if ($post->post_type == $posttype) {
    mail('email@email.com','new job published','done new job publish');
   }


 }
add_action( 'publish_post', 'newJobAdded' );
Run Code Online (Sandbox Code Playgroud)

但是,当我这样做时没有任何反应.我错过了一些简单化和无趣的东西吗?

php wordpress hook custom-post-type

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

.NET MVC显示ViewData()

对,就这样.我在Visual Studio类型的Internet应用程序中创建了一个新项目.

在HomeController.vb文件中,我有:

Function Index() as ActionResult
    ViewData("Message") = "Page Title"
    Return View()
End Function
Run Code Online (Sandbox Code Playgroud)

在'Index.aspx'视图中,我需要在我拥有的'<h1>'标签之间显示该视图数据.

我环顾四周,发现有人说要输入:

 <%= ViewData["Message"] %>
or
 <% @ViewData["Message"] %>
Run Code Online (Sandbox Code Playgroud)

但这些都不起作用:(

asp.net-mvc

0
推荐指数
1
解决办法
8153
查看次数