草庐IT

swift - ios8/swift : Buttons inside UICollectionView Cell?

我正在尝试使用CollectionView将“上传图像”的预览构建到服务器,但不知何故我被删除了——或者更准确地说,如何正确连接单元格内的按钮?单击X(单元格内的一个按钮)时,用户应该从属于其父ViewController的上传数组中删除此UIImage。您应该在自定义单元格类中还是在普通ViewController中处理IBAction单击?正确的做法是什么?您应该根据索引在按钮上使用标签,然后删除图像@index还是应该将整个数组移交给单元格并在点击后返回? 最佳答案 假设按钮的TouchUpInside事件连接到下面的函数。f

ios - Swift 4.2 UITableView Cell 不会自动改变它的高度

我在自动调整单元格高度时遇到问题。单元格中有一个UILabel,它有一个很长的文本。但是,它是不可见的,因为单元格不会自动变大。importUIKitclassViewController:UIViewController{@IBOutletweakvartableView:UITableView!overridefuncviewDidLoad(){super.viewDidLoad()//Doanyadditionalsetupafterloadingtheview,typicallyfromanib.tableView.estimatedRowHeight=50tableView.

iOS Collection View : how to scroll a cell to the top of the screen

我想知道是否有办法将某个UICollectionViewCell滚动到View的顶部?我尝试了collectionView.scrollToItemAtIndexPath()方法,但不是将单元格滚动到View的顶部,而是将单元格滚动到View的中心。 最佳答案 您可以使用以下代码:#pragmamark-UICollectionViewDelegate-(void)collectionView:(UICollectionView*)collectionViewdidSelectItemAtIndexPath:(NSIndexPath

ios - "unable to dequeue a cell with identifier"当切换到编程转换而不是 segue 时

我有2个View,一个里面有一个按钮的主视图,一个表格View。TableView单元格具有标识符“ResultsTableViewCell”。我的目标是当我按下主视图上的按钮时,我会转换到表格View当我使用Storyboardsegue时,一切正常。但是,当我取出segue而不是为按钮分配一个Action以编程方式进行转换时,我得到了提到的错误。这是为什么?代码如下:ViewController.swift(这是我进行任何更改的唯一文件)classViewController:UIViewController{overridefuncviewDidLoad(){super.view

ios - swift : UITableViewCell separator for the first the cell only

我想显示不带分隔符的评论,如下图所示我尝试使用分隔符但它不起作用我只需要第一个单元格的分隔符。super.viewDidLoad()self.commentstableView.separatorColor=UIColor.clearColor()functableView(tableView:UITableView,cellForRowAtIndexPathindexPath:NSIndexPath)->UITableViewCell{//post'ssection==0ifindexPath.section==0{letcell=tableView.dequeueReusableC

ios - 从自定义 Cell 中正确委托(delegate)按钮操作以删除 UITableView 中的行

仍然是一个Swift菜鸟,我一直在寻找一种正确的方法/最佳实践来管理我的UITableView(使用自定义UserCell)中的行删除基于使用委托(delegate)在UserCell中点击UIButton,这似乎是最简洁的方法。我按照这个例子:UITableViewCellButtonswithaction我有什么UserCell类protocolUserCellDelegate{funcdidPressButton(_tag:Int)}classUserCell:UITableViewCell{vardelegate:UserCellDelegate?letaddButton:UI

ios - 用户界面测试 : Slider fails to adjust when nested in Table View Cell

在Xcode9.0(9A235)上的UI测试中,当UISlider时,使用adjust(toNormalizedSliderPosition:)与UISlider交互根本不起作用嵌套在UITableViewCell中。我已经在许多不同的场景中进行了测试:-未嵌入UITableView的普通UISlider可与adjust方法一起正常工作。-与UITableView共存但不在TableViewCell中的UISlider继续与adjust配合使用-UITableView中的UISlider可以被唯一标识。-在UITableView中标识的UISlider可以响应像tap()这样的简单事件

ios - 在 NavBar 上使用 Back 后,RefreshControl 会导致 TableView 的第一个 Cell 出错

我在NavigationController中嵌入了一个TableView(并且嵌入在TabBarController中)。我在每个单元格中都有一个用户名按钮,可以连接到用户的个人资料。然而,当我在个人资料页面的导航栏上点击“返回”并返回到tableview后,似乎我遇到了一些问题。如果我再次下拉,它会刷新,但这次,顶行的用户名变得不可点击,而其他行按预期工作。请注意,我在tableView的viewDidLoad中调用了self.theRefreshControl=UIRefreshControl(),但我不确定在使用后它是否被调用返回键。请注意,我使用prepareForSegue

ios - 关于UITableView如何复用cell的几个问题

以下所有问题均基于使用此方法:functableView(tableView:UITableView,cellForRowAtIndexPathindexPath:NSIndexPath)->UITableViewCell{letcell=tableView.dequeueReusableCellWithIdentifier("CustomUserTableViewCell",forIndexPath:indexPath)as!CustomUserTableViewCellcell.user_id=items[indexPath.row]returncell}可以说UITableVie

ios - swift -UITableView 'unable to dequeue a cell with identifier Cell'

我正在使用Swift开发一个iOS项目。此应用涉及在UITableView中显示JSON数据。我已经解析了JSON数据,但它没有显示在表格View中。每当我运行我的应用程序时,它都会给我这个错误:Terminatingappduetouncaughtexception'NSInternalInconsistencyException',reason:'unabletodequeueacellwithidentifierCell-mustregisteraniboraclassfortheidentifierorconnectaprototypecellinastoryboard'我正在