小编jMe*_*nik的帖子

当app处于前台模式时,如何禁用iPhone/iPad自动锁定?

我正在开发一个音乐/视频播放器应用程序,只需要知道如何在我的应用程序处于前台时禁用自动锁定.

我知道我已经使用[[UIApplication sharedApplication] setIdleTimerDisabled:YES];,并[[UIApplication sharedApplication] setIdleTimerDisabled:NO];在某些时候,但如果是把他们最好的地方?

iphone foreground ipad ios auto-lock

29
推荐指数
3
解决办法
2万
查看次数

iOS 6流媒体播放器com.apple.coremedia.networkbuffering错误

我在iOS 6模拟器上运行我的应用程序(音乐和视频流播放器)时遇到了麻烦.

当我开始播放音乐时,它崩溃,在此主题上显示错误:com.apple.coremedia.networkbuffering

这个日志信息:

2012-09-13 17:45:09.260 app[32563:c07] [MPAVController] Autoplay: Disabling autoplay for pause
2012-09-13 17:45:09.260 app[32563:c07] [MPAVController] Autoplay: Disabling autoplay
2012-09-13 17:45:09.305 app[32563:c07] [MPAVController] Autoplay: Enabling autoplay
2012-09-13 17:45:09.307 app[32563:c07] handlePlaybackNowPlayingNotification
2012-09-13 17:45:09.308 app[32563:c07] [MPAVController] Autoplay: Likely to keep up or full buffer: 0
2012-09-13 17:45:09.308 app[32563:c07] [MPAVController] Autoplay: Skipping autoplay, not enough buffered to keep up.
2012-09-13 17:45:09.318 app[32563:c07] [MPAVController] Autoplay: Enabling autoplay
2012-09-13 17:45:09.320 app[32563:c07] [MPCloudAssetDownloadController] Prioritization requested for media item ID: 0
Run Code Online (Sandbox Code Playgroud)

我正在使用基于http的流的MPMoviePlayerController,它在iOS 4或iOS 5上运行良好

关于如何修复它的任何想法?

streaming mpmovieplayercontroller ios ios-simulator ios6

17
推荐指数
3
解决办法
2万
查看次数

无限的UIScrollView在iOS4.3而不是iOS5中会出现奇怪的行为

我已经实现了一个包含UIViews的无限UIScrollView.在iOS5(模拟器和iphone)中滚动时,它可以很好地工作.但是在iOS 4.3(SIM和手机)中它有点疯狂,滚动传递的视图比它应该多(比iOS5大10-15倍的视图).并且为了让它更奇怪,如果我慢慢拖动它会按预期工作,所以它在我释放后不会继续滚动.

设置有点简单,我扩展了UIScrollView类.并添加宽度约为1500pt的UIView,在此添加我想要滚动的UIViews.滚动时,如果视图不在屏幕上,则会添加和删除视图.

我认为我的问题在于此代码:

 - (void)recenterIfNecessary {
    CGPoint currentOffset = [self contentOffset];
    CGFloat contentWidth = [self contentSize].width;
    CGFloat centerOffsetX = (contentWidth - [self bounds].size.width) / 2.0;
    CGFloat distanceFromCenter = fabs(currentOffset.x - centerOffsetX);
    UIView *image;

    if (distanceFromCenter > (contentWidth / 4.0)) {
        // Recenter the ScrollView so we never reach the edge
        self.contentOffset = CGPointMake(centerOffsetX, currentOffset.y);
        // Move visiblePhotos to new position to adjust to new contentOffset
        for (image in visiblePhotos) {
            CGPoint center = image.center;
            center.x += (centerOffsetX - currentOffset.x); …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c uiscrollview

4
推荐指数
1
解决办法
1788
查看次数

将UIImage保存为其他名称

我正在编写一个应用程序,让用户从选择中选择一张照片.然后我想将照片保存到他们的照片卷到一个特定的名称.即我总是希望将卷中的照片命名为相同的东西,并覆盖以前的选择.

    UIImage* image = [UIImage imageNamed:[ImageNames objectAtIndex:self.miImage]];

    UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);
Run Code Online (Sandbox Code Playgroud)

无论如何,我找不到制作图像的副本并为其指定新名称,或为UIImageWriteToSavedPhotosAlbum()指定目标名称.

有没有办法做到这一点?

提前致谢,

松鸦

iphone objective-c uiimage

1
推荐指数
1
解决办法
1909
查看次数

重用细胞...... :(

我有一个包含9个部分和56行的表格.

我想为每个单元格添加文本标签.我创建了一个NSArray menuList56 NSDictionaries和一个包含每个部分(sectionsArray)行数的数组.

这是我的代码,但它根本无法正常工作:

// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    //Use existing cell (reusable)
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier];

    //If no existing cell, create a new one
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:kCellIdentifier] autorelease];

        //Define cell accessory type
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

        //Create a subView for the cell
        CGRect subViewFrame = cell.contentView.frame;
        subViewFrame.origin.x += kInset;
        subViewFrame.size.width = kInset + kSelectLabelWidth;

        UILabel …
Run Code Online (Sandbox Code Playgroud)

objective-c reusability uitableview ios4 ios

0
推荐指数
1
解决办法
3508
查看次数

MPMusicPlayerController不能在后台播放

我在我的应用程序中使用MPMusicPlayerController,当我进入后台时它停止播放.

这就是我添加它的方式:

musicPlayer = [MPMusicPlayerController iPodMusicPlayer];
Run Code Online (Sandbox Code Playgroud)

iphone objective-c mpmusicplayercontroller

0
推荐指数
1
解决办法
2657
查看次数