我使用 UITableViewController 来显示 KoreanFood 的详细信息。第一个单元格是一个自定义 UITableViewCell (OverviewCell),带有一个图像和两个 UITextField,我在 Storyboard (AutoLayout) 中创建并布局了它。
我像这样子类化 UITableviewCell :
// OverviewCell.h
@interface OverviewCell : UITableViewCell
@property (strong, nonatomic) IBOutlet UITextField *englishTitleTF;
@property (strong, nonatomic) IBOutlet UITextField *koreanTitleTF;
@property (strong, nonatomic) IBOutlet UIImageView *myImageView;
@property (strong, nonatomic) UIImage *thumbnail;
Run Code Online (Sandbox Code Playgroud)
我在 Storyboard 中的文本字段设置为启用/UserInteractionenabled,委托人是我的 TVC。当我创建单元格时,我也在代码中执行此操作:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == GENERAL_SECTION) {
static NSString *overviewCellID = @"overviewCell";
OverviewCell *overviewCell = [tableView dequeueReusableCellWithIdentifier:overviewCellID forIndexPath:indexPath];
overviewCell.englishTitleTF.text = self.generalInfo.titleEnglish;
overviewCell.koreanTitleTF.text = self.generalInfo.titleKorean;
overviewCell.englishTitleTF.enabled = YES;
overviewCell.koreanTitleTF.enabled …Run Code Online (Sandbox Code Playgroud) 我将 aUICollectionView与 a 结合使用NSFetchedResultsController。当我获取新数据时,我将它们放入 SQLite 数据库中,并且我的 frc 会收到它将更新的通知。我实现了适当的委托方法并在批量更新中插入新数据,之后我不再调用reloadData。但是一旦插入数据,collectionview就会滚动到顶部(以使新项目可见?)。我想干预这个过程并模仿 Facebook/9Gag 的实现。当有新数据时,一个按钮会淡出,让用户滚动到顶部。显示按钮时,新项目已经插入,因此用户也可以自己向上滚动。我尝试了以下方法:
UIScrollViewDelegate方法,看看是否可以阻止 collectionView 滚动(在此更新过程中没有调用任何方法)willUpdate,并在按下按钮时插入项目。问题是用户无法自己向上滚动uiscrollview nsfetchedresultscontroller ios uicollectionview swift