小编Mc.*_*ver的帖子

强制键盘显示通过按钮(iOS)

我有一个UITextView,我不想检查可编辑选项,如何通过按钮调用键盘?这段代码对我不起作用!

-(IBAction) yourButtonClick
{
    [myTextView becomeFirstResponder];
    [self.view addSubview:myTextView]; 
}
Run Code Online (Sandbox Code Playgroud)

iphone uitextview uikeyboard ios

5
推荐指数
1
解决办法
2万
查看次数

进入后台时,MPMoviePlayerViewController变为黑色

我有MPMoviePlayerViewController的问题,当应用程序进入后台然后我再次启动它或去另一个viewControllers电影变黑!我的电影在我的菜单背景中播放,这是我的代码:

EIDTED代码:

    -(void)viewDidLoad {
        [self moviePlayer2];
    } 

   - (void) moviePlayer2 {



    NSString *path = [[NSBundle mainBundle] pathForResource:@"cloud" ofType:@"mp4"];
    player = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL fileURLWithPath:path]];
    player.view.userInteractionEnabled = YES;    
    player.moviePlayer.repeatMode = YES;
    player.moviePlayer.scalingMode = MPMovieScalingModeFill;
    player.moviePlayer.controlStyle = MPMovieControlStyleNone;

    [[NSNotificationCenter defaultCenter] addObserver:self 
                                             selector:@selector(moviePlayBackStateChange:) 
                                                 name:MPMoviePlayerPlaybackStateDidChangeNotification
                                               object:[player moviePlayer]];

     [[player moviePlayer] play];

    [self.view addSubview:player.view]; 

}


-(void) moviePlayBackStateChange: (NSNotification *) note {

    [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackStateDidChangeNotification object:[player moviePlayer]];

    [[player moviePlayer] play];

    //[player release];
    NSLog(@"FINISHED");
}
Run Code Online (Sandbox Code Playgroud)

谢谢 .

iphone xcode mpmovieplayercontroller ipad ios

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

iPad上的低质量捕获视图上下文

我需要捕获特定的UIView,但结果是低质量如何解决这个问题并提高质量?

UIGraphicsBeginImageContext(captureView.bounds.size);
    [captureView.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *screenshot = UIGraphicsGetImageFromCurrentImageContext();
    UIImageWriteToSavedPhotosAlbum(screenshot, nil, nil, nil);
    UIGraphicsEndImageContext();
Run Code Online (Sandbox Code Playgroud)

iphone sdk xcode ipad ios

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

UIImagePickerControllerEditedImage问题

我需要在导入到应用程序之前编辑我的图像但是在编辑图像后降低了一些质量如何避免这种情况?

- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {

    [self dismissModalViewControllerAnimated:YES];
    imgEdited.image = [info objectForKey:UIImagePickerControllerEditedImage];


}
Run Code Online (Sandbox Code Playgroud)

iphone xcode objective-c ios ios5

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

在SKScene上呈现一个viewController

我试图呈现UIActivityViewController一个SkView 但是xcode给了我这个错误:

'GameOver'没有可见的@interface声明选择器'presentViewController:animated:completion:'

- (void)shareScore {

    //add view
    UIView *Sview  = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 512, 512)];
    UIImageView *image = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"shareScoreImg.png"]];
    image.frame = Sview.frame;
    [Sview addSubview:image];

    //add label
    CGRect fframe = self.view.frame;

    UILabel *score = [[UILabel alloc] initWithFrame:fframe];
    score.text = @"9999";
    score.textAlignment = NSTextAlignmentCenter;
    score.textColor = [UIColor darkGrayColor];
    score.center = CGPointMake(250, 440);
    score.font = [UIFont fontWithName:@"Pixel LCD7" size:50];
    [Sview addSubview:score];


    //capture view
    UIGraphicsBeginImageContextWithOptions(Sview.bounds.size, Sview.opaque, 0.0);
    [Sview.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage * screenshot = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    UIActivityViewController* activityViewController = …
Run Code Online (Sandbox Code Playgroud)

iphone xcode objective-c ios sprite-kit

5
推荐指数
2
解决办法
6424
查看次数

UIPageViewController并删除当前视图控制器

我设置UIPageViewController为前进和后退一些视图控制器.我有一个问题,当视图控制器添加到UIPageViewController内存使用量将增加,直到编译器给我Received memory warning,然后应用程序运行太慢,直到应用程序清空内存并再次正常工作.如何在不增加内存的情况下浏览视图控制器?或者更好地说当新的on添加时如何删除当前视图控制器.这是我的代码:

// Create the page view controller.
self.pageViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"PageViewController"];
self.pageViewController.dataSource = self;


//disabling tap and swipe guesture
for (UIGestureRecognizer *recognizer in self.pageViewController.gestureRecognizers) {
    recognizer.enabled = NO;
}


// Instantiate the first view controller.
UIViewController *startingViewController = [self viewControllerAtIndex:0];

[self.pageViewController setViewControllers:@[startingViewController]
                                  direction:UIPageViewControllerNavigationDirectionForward
                                   animated:NO
                                 completion:^(BOOL finished) {
                                     // Completion code
                                 }];

// Add the page view controller to this root view controller.
[self addChildViewController:self.pageViewController];
[self.view addSubview:self.pageViewController.view];
[self.pageViewController didMoveToParentViewController:self];
Run Code Online (Sandbox Code Playgroud)

前进和后退行动:

- (void)goToPreviousContentViewController
{ …
Run Code Online (Sandbox Code Playgroud)

iphone xcode objective-c ios uipageviewcontroller

5
推荐指数
2
解决办法
1629
查看次数

在允许代码签名使用我的钥匙串方面存在问题

我正在使用El Capitan和Xcode 7.1,我正在尝试构建和存档我的应​​用程序以上传到应用商店.编译此警报后弹出: 在此输入图像描述

Always AllowAllow按钮不能在所有的工作,但Deny取消了警报!我该如何解决这个问题?我正在使用新的iMac并将旧Mac中的所有数据传输到这个新的.Safari当网站想要从钥匙串访问密码时,甚至会出现此问题.

这是控制台日志:

SecurityAgent [1476]:忽略用户操作,因为对话框已收到来自不受信任来源的事件

我已经调查了这个问题,但我没有分享任何东西!

iphone xcode code-signing keychain ios

5
推荐指数
2
解决办法
7464
查看次数

滚动到 UICollectionView 中启用分页的页面

我正在尝试将数字(页码)从视图控制器传递到另一个具有UICollectionView选项的视图控制器paging enabled。我的代码确实滚动到页面,但内容未居中,这是我的代码:

override func viewWillAppear(_ animated: Bool) {
    let currentPage = 4
    let indexPath = NSIndexPath(row: currentPage , section: 0) as IndexPath
    self.collectionView.scrollToItem(at: indexPath, at: .right, animated: true)
}
Run Code Online (Sandbox Code Playgroud)

结果 :

在此输入图像描述

我需要的 :

在此输入图像描述

解决方案 :

collectionView.setContentOffset(CGPoint(x:  CGFloat(currentPage) * collectionView.bounds.size.width , y: 0), animated: false)
Run Code Online (Sandbox Code Playgroud)

编辑

func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {

        return CGSize(width: 321 , height: 321)

    }
Run Code Online (Sandbox Code Playgroud)

iphone xcode ios uicollectionview swift

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

反向 AVPlayer 反向播放问题

我正在尝试向正在播放的视频添加反向播放AVPlayer

let videoURL = Bundle.main.url(forResource: "video", withExtension: "mov")
videoPlayer = AVPlayer(url:videoURL!)
let playerLayer = AVPlayerLayer(player: videoPlayer)
playerLayer.frame = self.view.frame
videoView.layer.addSublayer(playerLayer)
videoPlayer.play()
Run Code Online (Sandbox Code Playgroud)

我搜索并发现是否将AVPlayer's rate更改为以-1反向模式播放的电影:

 func reverseVideo()  {

        videoPlayer.play()
        videoPlayer.rate = -1
    }
Run Code Online (Sandbox Code Playgroud)

这确实工作正常,但反向播放包含很多延迟并且播放不流畅,是否有任何可能的方法来解决此问题。我在这里阅读了其他主题,但没有帮助。

xcode ios avplayer swift

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

使用Xcode 4.2在Interface Builder中使用UIApplicationDelegate

我的应用程序是基于视图的应用程序.我需要创建一个UINavigationController作为我的rootViewController.

在以前版本的Xcode中,有一个命名的xib文件mainWindow,我们可以在其中:

  • 我们的连接UIApplicationDelegate实现对UIApplicationdelegate出口
  • 连接UIWindowUIApplicationDelegate
  • 连接UIViewControllerUIWindowrootViewController财产.

但是现在(Xcode 4.2)不会创建这个xib文件!

那么如何创建自定义UINavigationController并将其连接到UIApplicationDelegateInterfaceBuilder中的实现?

这是我的UIApplicationDelegate实现中的代码:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    SDWebImageRootViewController *root = [[SDWebImageRootViewController alloc] initWithNibName:nil bundle:nil];

    _navigationController = [[[UINavigationController alloc] initWithRootViewController:root] autorelease];

     self.window.rootViewController = _navigationController;

    [[_navigationController navigationBar] setBarStyle:UIBarStyleBlack];
    [[_navigationController navigationBar] setTranslucent:YES];

    [_window addSubview:[_navigationController view]];
}
Run Code Online (Sandbox Code Playgroud)

iphone sdk xcode ipad ios

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