我正在将项目更新到iOS 8,并且正在使用我的一个UITableViewCell实现来解决这个问题.目前在模拟器上而不是设备,它被设置为"iPhone 6".
*** Assertion failure in -[UITableViewCell _setHostsLayoutEngine:], /SourceCache/UIKit_Sim/UIKit-3318/NSLayoutConstraint_UIKitAdditions.m:2754
2014-09-15 10:43:52.890 BasketballStatTracker[10662:304085] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Must translate autoresizing mask into constraints to have _setHostsLayoutEngine:YES.'
Run Code Online (Sandbox Code Playgroud)
奇怪的是我在所有其他UITableViews中使用这个自定义UITableViewCell子类,它运行良好,没有任何断言.
这是cellForRowAtIndexPath:实现.
MyTableCell *cell =(MyTableCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell =[[MyTableCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
Run Code Online (Sandbox Code Playgroud)
这是堆栈跟踪
0 CoreFoundation 0x000000010844e3f5 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x00000001080e7bb7 objc_exception_throw + 45
2 CoreFoundation 0x000000010844e25a +[NSException raise:format:arguments:] + 106
3 Foundation 0x0000000107ac228f -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 195
4 UIKit 0x0000000106de2e1c -[UIView(AdditionalLayoutSupport) _setHostsLayoutEngine:] …Run Code Online (Sandbox Code Playgroud) 我有一个在后台播放音频的应用程序.我正在尝试修复主屏幕(等)上音频控件(播放/暂停)的错误,不能在iOS 8.0上运行,但在iOS 7.0上运行FINE.我一直在努力弄清楚问题是什么,并且一直空洞.任何想法将不胜感激.这就是我所拥有的.
在项目设置中:我已确保UIBackgroundModes设置为audio.
在AppDelegate.h中:我有一个成员AVAudioSession* session;以及AVPlayer *audioPlayer;
在AppDelegate.m中:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
self.session = [AVAudioSession sharedInstance];
NSError* error = NULL;
[self.session setCategory:AVAudioSessionCategoryPlayback error:&error];
[self.session setActive:YES error:&error];
if (error) {
NSLog(@"AVAudioSession error: %@", [error localizedDescription]);
}
Run Code Online (Sandbox Code Playgroud)
在AudioPlayerViewController.m中
- (void)viewDidLoad {
//Get the Audio
NSURL *url = [NSURL URLWithString:self.audioUrl];
AVAsset *asset = [AVURLAsset URLAssetWithURL:url options:nil];
//Setup the player
self.playerItem = [AVPlayerItem playerItemWithAsset:asset];
appDelegate.audioPlayer = [AVPlayer playerWithPlayerItem:self.playerItem];
//Setup the "Now Playing"
NSMutableDictionary *mediaInfo = [[NSMutableDictionary …Run Code Online (Sandbox Code Playgroud)