Tag: tableviewcell

如何检测tableview单元格中的多个button

如何检测tableview单元格中的多个button,我的疑问是与例如我有3个button单元格中,如果我点击一个button,该button将改变颜色,如果我点击indexpath.row = 1单元格button,该button将颜色也需要改变帮助我

检查一个UITableViewCell是否完全可见

我怎样才能检查一个UITableViewCell是否完全可见在屏幕上(不切断标签或导航栏)? 我可以用这个代码得到可见的单元格: NSArray *indexes = [_tableView indexPathsForVisibleRows]; 但我想排除在屏幕上不完全可见的单元格。

将UITableView添加到现有的ViewController

我试图以编程方式将UITableView添加到现有的UIViewController 。 我的run.h文件有这样的: @interface runTests : UIViewController <UINavigationControllerDelegate,UITextFieldDelegate,UIAlertViewDelegate,UITableViewDelegate,UITableViewDataSource> {NSTimer *Timer;} @property (strong, nonatomic) UITableView *tableView; 我的应用程序运行速度testing,并在testing结束时,我试图添加一个TableView到视图。 目前我有这个: -(void)addSpeedTable { self.tableView = [[UITableView alloc] initWithFrame:self.view.bounds]; self.tableView.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth; self.tableView.rowHeight = 45; self.tableView.sectionFooterHeight = 22; self.tableView.sectionHeaderHeight = 22; self.tableView.delegate = self; self.tableView.dataSource = self; [self.view addSubview:self.tableView]; } – (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } – (NSInteger)tableView:(UITableView *)tableView […]

如何根据具有打字机效果的UILabel设置单元格的高度

我在UITableView的单元格中有一个UILabel。 要根据标签的高度来调整单元格的高度,没关系,它可以很好地工作。 但是我需要添加另一个约束。 我需要用打字机效果(逐字母)显示UILabel。 我的扩展效果很好: extension UILabel{ func setTextWithTypeAnimation(id:String, typedText: String, pauseCharacterArray: [Int:Double], characterInterval: TimeInterval = 0.06 ) { text = "" let group = DispatchGroup() group.enter() DispatchQueue.global(qos: .userInteractive).async { for (index, character) in typedText.characters.enumerated() { DispatchQueue.main.async { self.text = self.text! + String(character) } Thread.sleep(forTimeInterval: characterInterval) } group.leave() } group.notify(queue: .main) { //do something } […]

更改自定义单元格中button的图像

我想要更改自定义单元格上的button的图像,给定的代码更改图像双击。我想改变图像单击(选中和取消选中) – (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *simpleTableIdentifier = @"SimpleTableCell"; SimpleTableCell *cell = (SimpleTableCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier]; if (cell == nil) { NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"SimpleTableCell" owner:self options:nil]; cell = [nib objectAtIndex:0]; } NSString *localArrayData = [LocalArray objectAtIndex:indexPath.row]; cell.nameLabel.text =localArrayData; cell.CheckButton.tag=indexPath.row; [cell.CheckButton setImage:[UIImage imageNamed:@"checkU.png"] forState:UIControlStateNormal]; [cell.CheckButton addTarget:self action:@selector(CheckButtonAction:)forControlEvents:UIControlEventTouchUpInside]; return cell; } […]

如何将一个button添加到iOS中的表格视图单元格?

我正在Swift中创build一个生产力应用程序。 我没有使用Storyboard中的原型单元格,因为它大部分已经被编写在代码中了。 我想要一个checkboxbutton。 我将如何去做呢?

如何维护NSUserDefaults中的单元格select?

https://github.com/lminhtm/LMDropdownView 我怎样才能保存最后select的单元格在NSUserDefault? 当应用程序重新打开时,应该保持select。 目前,每当应用程序打开时,都会select默认单元格。 – (void)viewDidLoad { [super viewDidLoad]; self.mapTypes = @[@"Standard", @"Satellite", @"Hybrid"]; self.currentMapTypeIndex = 0; self.dropPinButton.layer.cornerRadius = 5; self.removeAllPinsButton.layer.cornerRadius = 5; self.moreButton.layer.cornerRadius = 5; self.moreButton.layer.shadowOffset = CGSizeZero; self.moreButton.layer.shadowOpacity = 0.5; self.moreButton.layer.shadowRadius = 1.0; } – (void)viewDidLayoutSubviews { [super viewDidLayoutSubviews]; self.menuTableView.frame = CGRectMake(CGRectGetMinX(self.menuTableView.frame), CGRectGetMinY(self.menuTableView.frame), CGRectGetWidth(self.view.bounds), MIN(CGRectGetHeight(self.view.bounds) – 50, self.mapTypes.count * 50)); self.moreBottomView.frame = CGRectMake(CGRectGetMinX(self.moreBottomView.frame), […]

Swift UITextField文本通过TableViewCell中的button操作清除

我logging了我的屏幕, 这里是它的链接 。 进入细节 我有一个tableView部分,其中有一个tableviewcell( PhoneCell )有两个文本框(一个是pickerviewinput和其他文本框),和一个添加button。 点击添加button时,我将一个空电话附加到电话arrays(重复使用相同的PhoneCell)并调用tableView.reloadData()方法。 问题 :( 每当我点击添加button,我input的textFields文本被清除。 我想保留它,最终应该能够保存数据(用户input的电话数量),当我点击Save_Button 添加电话button操作码: func addUserPhone(userData: MyUserData) { self.user = userData var emptyPhoneDict:[String:String] = ["country":"", "number":""] if (user.phones?.count < 4) { var emptyPhone : MyUserPhoneNumber = MyUserPhoneNumber(dictionary: emptyPhoneDict)! emptyPhone.country = "" emptyPhone.number = "" user.phones?.append(emptyPhone) } } 在我的PhoneCell.swift类中,我有下面的方法,正在照顾数据和indexPath值 override func configure(withUser user: MyUserData, language: String, indexPath: […]

如何在Swift 2单元格中删除项目后重新加载tableview

我有一个TableView中的帐户列表。 按下button后,项目被删除。 到现在为止还挺好。 删除后如何刷新tableView? 请find下面的屏幕截图了解更多信息。 TableView是在另一个ViewController中,要删除的button是在一个ViewControllerCell中 class cellAccount: UITableViewCell { @IBOutlet weak var imgAccount: UIImageView! @IBOutlet weak var lblNomeAccout: UILabel! @IBOutlet weak var btnDeletar: UIButton! @IBAction func btnDeletar(sender: AnyObject) { print(btnDeletar.titleLabel?.text) if (bdAccount.indexOf((btnDeletar.titleLabel?.text)!) != nil) { print(bdAccount.indexOf((btnDeletar.titleLabel?.text)!)) bdAccount.removeAtIndex(bdAccount.indexOf((btnDeletar.titleLabel?.text)!)!) bdAccount.sortInPlace() self.tableView.reloadData() // How to Reload??? } } override func awakeFromNib() { super.awakeFromNib() // Initialization code } […]

来自TableViewCell的presentViewController

我有一个TableViewController,TableViewCell和一个ViewController。 我在TableViewCell中有一个button,我想用presentViewController来呈现ViewController(但是ViewController在Storyboard上没有视图)。 我试过使用: @IBAction func playVideo(sender: AnyObject) { let vc = ViewController() self.presentViewController(vc, animated: true, completion: nil) } 错误:typesTableViewCell的值没有成员presentViewController 然后,我试了一下 self.window?.rootViewController!.presentViewController(vc, animated: true, completion: nil) 错误:警告:尝试呈现其视图不在窗口层次结构中! 我究竟做错了什么? 我应该怎么做才能从TableViewCell呈现ViewController? 另外我怎样才能将数据传递给TableViewCell中的新呈现VC? 更新: protocol TableViewCellDelegate { buttonDidClicked(result: Int) } class TableViewCell: UITableViewCell { @IBAction func play(sender: AnyObject) { if let id = self.item?["id"].int { self.delegate?.buttonDidClicked(id) } } } […]