小编Vic*_*ora的帖子

iOS Swift,使用标记在tableview CellForRow之外更新UITableView自定义单元格标签

安装程序(Swift 1.2/iOS 8.4):

我在UIViewController中有UITableView自定义单元格(标识符= Cell).在自定义TableView单元格中有两个按钮(递增/递减计数)和一个标签(显示计数).

目标:

按下增加计数或减少计数按钮时更新标签.

目前我能够获得按钮Tag并调用CellForRowAtIndexPath之外的函数.按下按钮可增加和减少计数.但我无法在标签中显示计数更新.

 func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

    let cell:FoodTypeTableViewCell = self.tableView!.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! FoodTypeTableViewCell

    cell.addBtn.tag = indexPath.row // Button 1
    cell.addBtn.addTarget(self, action: "addBtn:", forControlEvents: .TouchUpInside)

    cell.subBtn.tag = indexPath.row // Button 2
    cell.subBtn.addTarget(self, action: "subBtn:", forControlEvents: .TouchUpInside)

    cell.countLabel.text = // How can I update this label
    return cell
}

func addBtn(sender: AnyObject) -> Int {
    let button: UIButton = sender as! UIButton
    count = 1 + count
    println(count)
    return count …
Run Code Online (Sandbox Code Playgroud)

uitableview ios swift

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

ViewController中的UITableView,带有自定义单元格而没有故事板

我正在使用Swift 2.0和Xcode 7.2.

我想学习如何制作没有故事板的应用程序(带有纯编程代码的UI).首先,我试图在一个自定义UITableView单元格中创建一个带有三个标签的简单应用程序,该单元格将通过互联网动态更新.

这是我迄今取得的成就:

  • 创建了一个新的Swift项目并从项目中删除了main.storyboard
  • 添加了视图控制器作为rootViewControllerinAppDelegate
  • 包含UITableView在此视图中创建内部的代码

以下是我想要完成的其他任务(所有这些都是以编程方式完成的,不使用属性检查器):

  • 插入UINavigationControllerViewController
  • 添加带有三个标签的自定义单元格
  • 使用数据更新表视图

如果可能的话,我希望能够让一切都在横向模式下工作.

谁能告诉我怎么做?

AppDelegate.swift

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    // Override point for customization after application launch.

    window = UIWindow(frame: UIScreen.mainScreen().bounds)
    window!.backgroundColor = UIColor.whiteColor()
    window!.rootViewController = ViewController()
    window!.makeKeyAndVisible()
    return true
}
Run Code Online (Sandbox Code Playgroud)

ViewController.swift

import UIKit

class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {

    var tableView = UITableView()

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading …
Run Code Online (Sandbox Code Playgroud)

uitableview ios swift

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

ESP8266 使用 Arduino IDE 产生垃圾

我正在使用 ESP8266 板连接到 Arduino Nano 使用此视频。但是每次我打开电路板时,我都会得到像“¤HlzGà”这样的垃圾值。每次打开和关闭它都会改变。

我尝试使用不同的波特率和 ESP8266 板。但我得到了相同的结果。任何人都可以帮助我吗?

arduino esp8266

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

iOS Swift Facebook SDK 4获取用户个人资料图片输出"问号"

我不是编程专家,但我修改了一个代码来从Facebook SDK获取用户个人资料图片.问题是我在图像中得到一个问号(profilePicture.image).谁能告诉我这里发生了什么?

另外,我不知道如何在viewController中调用此函数来获取图像?目前我在函数内部直接添加了profilePicture.image.

   func getProfPic(fid: String) -> UIImage? {
            if (fid != "") {
                var imgURLString = "http://graph.facebook.com/" + fid + "/picture?type=large" //type=normal
                var imgURL = NSURL(string: imgURLString)
                var imageData = NSData(contentsOfURL: imgURL!)
                var image = UIImage(data: imageData!)
                profilePicture.image = image // Returned image is Question mark 
                return image
            }
            return nil
        }
Run Code Online (Sandbox Code Playgroud)

facebook ios swift

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

标签 统计

ios ×3

swift ×3

uitableview ×2

arduino ×1

esp8266 ×1

facebook ×1