我的工作是关于`UITableView.每次运行我的项目时,都会出现此错误:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'unable to dequeue a cell with identifier Cell1 - must register a nib or a class for the identifier or connect a prototype cell in a storyboard
Run Code Online (Sandbox Code Playgroud)
我在故事板中检查了我的单元标识符一百次,在我的代码中是相同的.代码(defaut代码UITableViewController):
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell1";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
// Configure the cell...
return cell;
}
Run Code Online (Sandbox Code Playgroud)
表视图单元属性的图片:

我创建并实现了UITableViewCell我的单元格的子类.
知道为什么这不起作用吗?
任何方式(代码行)知道单元格的标识符是什么?
谢谢
编辑:我的界面构建器的屏幕截图.

编辑2:customCell.h的文本
#import <UIKit/UIKit.h>
@interface customCell : UITableViewCell
@end …Run Code Online (Sandbox Code Playgroud) 是否可以显示pushViewController动画外观,presentModalViewController但具有背景功能pushViewController?
iphone animation pushviewcontroller presentmodalviewcontroller ios
从iOS 7到8,我的代码运行良好.昨天更新了我的引脚上的自定义图像被标准引脚图像替换.有什么建议?
我的代码:
extension ViewController: MKMapViewDelegate {
func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView! {
if annotation is MKUserLocation {
return nil
}
let reuseId = String(stringInterpolationSegment: annotation.coordinate.longitude)
var pinView = mapView.dequeueReusableAnnotationViewWithIdentifier(reuseId) as? MKPinAnnotationView
if pinView == nil {
pinView = MKPinAnnotationView(annotation: annotation, reuseIdentifier: reuseId)
pinView!.canShowCallout = true
pinView!.image = getRightImage(annotation.title!!)
}
let button = UIButton(type: UIButtonType.DetailDisclosure)
pinView?.rightCalloutAccessoryView = button
return pinView
}
}
Run Code Online (Sandbox Code Playgroud)
获取图像的函数UIImage根据名称返回:
func getRightImage (shopName:String)-> UIImage{
var correctImage = UIImage()
switch shopName
{
case …Run Code Online (Sandbox Code Playgroud) 我想用来UICollectionView显示水平滚动的缩略图列表,但是,我希望这是一行.在另一个视图中,我正在显示缩略图,UICollectionView但是这个缩略图垂直滚动,它在一列中.
目前,我这样做的方法是将集合视图的大小更改为仅对一个项目足够大,以便自动装配和工作,但现在我正在处理可变大小的项目,因此它不再起作用.
如何UICollectionView显示一行或一列?
我有一个带有imageView的scrollView.这scrollView是superView的一个子视图,而imageView是一个子视图scrollView.我还有一个标签(在超级视图级别),每隔毫秒从NSTimer接收其text属性的更新值.
问题是:在滚动期间,标签停止显示更新.滚动结束时,标签上的更新将重新开始.更新重启时,它们是正确的; 这意味着label.text值按预期更新,但在滚动时,更新显示在某处覆盖. 无论滚动与否,我都希望在标签上显示更新.
以下是标签更新的实现方式:
- (void)startElapsedTimeTimer {
[self setStartTime:CFAbsoluteTimeGetCurrent()];
NSTimer *elapsedTimeTimer = [NSTimer scheduledTimerWithTimeInterval:0.001 target:self selector:@selector(updateElapsedTimeLabel) repeats:YES];
}
- (void)updateElapsedTimeLabel {
CFTimeInterval currentTime = CFAbsoluteTimeGetCurrent();
float theTime = currentTime - startTime;
elapsedTimeLabel.text = [NSString stringWithFormat:@"%1.2f sec.", theTime];
}
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助.
我有一个视图是UIViewController(根)处理广告和UINavigationController.在那个UINavigationController中,我有典型的控制器层.在我的自定义设置表视图控制器中,我有一个按钮与我联系以获得支持.当用户单击此按钮时,我创建了一个MFMailComposeViewController并希望呈现它.我无法从设置表视图中显示它,因为它将位于我的广告下方,因此我需要引用根视图并从那里显示它.我已经尝试过self.parentViewController.parentViewControllerself是设置表视图,但这不起作用.我应该如何参考.直接引用根视图并将其传递给设置视图似乎是一个糟糕的设计.
我在我的应用程序中使用了一个库UICollectionView.细胞大小约为70,70.我使用ALAssets从ALAssetLibrary我在其中已经存储在列表中的画廊.
我使用通常的模式来填充单元格:
-(UICollectionViewCell*)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
mycell = [collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath];
mycell.imageView.image = [[UIImage imageWithCGImage:[alassetList objectAtIndex:indexpath.row] thumbnail]];
return mycell;
}
Run Code Online (Sandbox Code Playgroud)
我的画廊滚动波涛汹涌.我不明白为什么会这样.我已经尝试添加一个NSCache来缓存缩略图(想想可能创建图像很昂贵),但这对性能没有帮助.
我希望用户界面像股票应用程序一样黄油.
我现在怀疑它可能是某种东西UICollectionViewCell prepareForReuse可能会阻碍dequeueReusableCellWithReuseIdentifier方法,但使用我无法找到的工具.
还有其他可能造成这种情况的事吗?是否有一种"更快"的方式以更快的方式UICollectionViewCell为dequeue它们做准备?
objective-c ios xcode-instruments uicollectionview uicollectionviewcell
我在xcode 5项目的autolayout上遇到了麻烦.我正在使用带有导航控制器的普通视图控制器.我有一个MKMapView在上半部分和一个UITableView在下半部分.我正在使用storyboards,并已配置原型UITableViewCell,但我通过代码添加约束.我已经仔细检查了原型中的每个控件,并且没有看到任何配置.我添加约束时出现问题UITableViewCell.我在单元格中有以下代码:
-(void)updateConstraints {
[super updateConstraints];
//first remove old constraints
[self removeConstraints:self.constraints];
[self.nameLabel removeConstraints:self.nameLabel.constraints];
[self.addressLabel removeConstraints:self.nameLabel.constraints];
[self.rentableSquareFeetLabel removeConstraints:self.rentableSquareFeetLabel.constraints];
[self.lastSaleAmountLabel removeConstraints:self.lastSaleAmountLabel.constraints];
[self.lastSaleDateLabel removeConstraints:self.lastSaleAmountLabel.constraints];
[self.thumbnailImageView removeConstraints:self.thumbnailImageView.constraints];
//then set up constraints
NSDictionary *viewsDictionary = NSDictionaryOfVariableBindings(_thumbnailImageView, _nameLabel, _rentableSquareFeetLabel, _lastSaleAmountLabel, _addressLabel, _lastSaleDateLabel);
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[_thumbnailImageView(60)]-[_nameLabel(<=200)]-(>=8)-[_rentableSquareFeetLabel]-(>=8)-[_lastSaleAmountLabel]|" options:0 metrics:nil views:viewsDictionary]];
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[_nameLabel]-(-4)-[_addressLabel]" options:NSLayoutFormatAlignAllLeading metrics:nil views:viewsDictionary]];
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[_lastSaleAmountLabel]-(-4)-[_lastSaleDateLabel]" options:NSLayoutFormatAlignAllLeading metrics:nil views:viewsDictionary]];
}
Run Code Online (Sandbox Code Playgroud)
我在调试控制台中收到以下内容.该异常由第一个addConstraints行触发.如果我只是继续通过那些,那么最终一切都显示应该是,因为看起来xcode正在选择打破正确的约束:
2013-09-25 15:07:14.169 PECProperties[32381:a0b] Unable to simultaneously satisfy constraints. Probably at least …Run Code Online (Sandbox Code Playgroud) 我有10个UIImageViews做同样的事情(他们有一些void方法,用计时器改变他们的图像).我的UIImageView是一个插座,我想将所有10个imageView连接到同一个插座,但界面构建器不允许我.
我发现有一个解决方案,IBOutletCollection.任何人都可以向我解释如何使用它将多个imageView连接到同一个插座?
我最近将我的一个测试iphone升级到iOS 8,然后升级了PUSH注册码,如下所示(使用xCode 6)
-(BOOL)hasNotificationsEnabled {
NSString *iOSversion = [[UIDevice currentDevice] systemVersion];
NSString *prefix = [[iOSversion componentsSeparatedByString:@"."] firstObject];
float versionVal = [prefix floatValue];
if (versionVal >= 8)
{
NSLog(@"%@", [[UIApplication sharedApplication] currentUserNotificationSettings]);
//The output of this log shows that the app is registered for PUSH so should receive them
if ([[UIApplication sharedApplication] currentUserNotificationSettings].types != UIUserNotificationTypeNone) {
return YES;
}
}
else
{
UIRemoteNotificationType types = [[UIApplication sharedApplication] enabledRemoteNotificationTypes];
if (types != UIRemoteNotificationTypeNone){
return YES;
}
}
return NO;
}
-(void)registerForPUSHNotifications { …Run Code Online (Sandbox Code Playgroud) ios ×9
objective-c ×6
iphone ×5
xcode ×3
uitableview ×2
animation ×1
autolayout ×1
identifier ×1
ios9 ×1
ipad ×1
mapkit ×1
mkannotation ×1
mkmapview ×1
push ×1
uiimageview ×1
uiscrollview ×1