小编Mc.*_*ver的帖子

有陀螺仪滚动图像的问题

iPad Air有一个奇怪的问题!,我的代码在iPad 3,iPad 4,iPhone 5S,iPod 5th Gen上运行良好,但在iPad上,我的图像自动滚动而无需用户旋转设备,这是我的代码:

 @property (strong, nonatomic) CMMotionManager *motionManager;


    self.mainScrollView.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);

    self.mainScrollView.bounces = NO;


    self.mainScrollView.userInteractionEnabled = NO;

    //set up the image view
    UIImage *image= [UIImage imageNamed:@"YOUR_IMAGE_NAME"];
    UIImageView *movingImageView = [[UIImageView alloc]initWithImage:image];
    [self.mainScrollView addSubview:movingImageView];

    self.mainScrollView.contentSize = CGSizeMake(movingImageView.frame.size.width, self.mainScrollView.frame.size.height);


    self.mainScrollView.contentOffset = CGPointMake((self.mainScrollView.contentSize.width - self.view.frame.size.width) / 2, 0);

    //inital the motionManager and detec the Gyroscrope for every 1/60 second
    //the interval may not need to be that fast
    self.motionManager = [[CMMotionManager alloc] init];
    self.motionManager.gyroUpdateInterval = 1/60; …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c ipad ios

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

以编程方式在底部的UIToolbar

我正在以UIToolbar编程方式创建,但问题是此工具栏的位置是否向上(导航栏位置).如何将其自动放在底部?

这是我的代码:

    CGRect rect2 = CGRectMake(0, toolBar.frame.origin.y , self.view.frame.size.width , 0);
    toolBar = [[UIToolbar alloc]initWithFrame:rect2];
    toolBar.barStyle = UIBarStyleBlackTranslucent;
    [toolBar sizeToFit];
    [self.view addSubview:toolBar];
    [toolBar release];
Run Code Online (Sandbox Code Playgroud)

因为我的应用程序是通用的,我的视图控制器类没有任何nib文件我需要为iPad和iPhone定义它,我不想使用UIUserInterfaceIdiomPad.

iphone objective-c uitoolbar ipad ios

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

在界面构建器中遇到Apple TV视图问题

我正在开发一个应用程序TvOS并具有与界面生成器的问题,当我拖累状物体Buttons,labels,段等..当前视图显示我什么!只有一个空白矩形,显示该对象的位置和区域

Apple TV  - 空白矩形

当我运行应用程序对象时会显示正常!

Apple TV  - 选择框

界面构建器有什么问题?

Xcode版本7.1(7B91b),OS X版本:10.11.1(15B42)

在屏幕截图的顶部有一个错误.

"发生内部错误.编辑功能可能受限"

xcode television storyboard tvos

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

iOS:创建简单的音频波形动画

我正在尝试录制音频AVAudioRecorder.我需要创建一个这样的简单波形:

在此输入图像描述

当用户对着麦克风说话时,圆圈表示用户语音的等级.我尝试使用此代码测量语音,但代码未检测到任何缓冲区而无法正常工作:

func levelTimerCallback(timer:Timer) {

    //we have to update meters before we can get the metering values
    audioRecorder.updateMeters()

    //print to the console if we are beyond a threshold value. Here I've used -7
    if audioRecorder.averagePower(forChannel: 1) > -7 {

        print(" level I'm hearin' you in dat mic ")
        print(audioRecorder.averagePower(forChannel: 0))
    }
}    
Run Code Online (Sandbox Code Playgroud)

录制音频:

func startRecording() {

        let audioSession = AVAudioSession.sharedInstance()
        do {

       // Audio Settings
            settings = [
                AVFormatIDKey: Int(kAudioFormatMPEG4AAC),
                AVSampleRateKey: 12000,
                AVNumberOfChannelsKey: 1,
                AVEncoderAudioQualityKey: AVAudioQuality.high.rawValue
            ]


            audioRecorder …
Run Code Online (Sandbox Code Playgroud)

iphone xcode avaudiorecorder ios swift

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

系统字体在 iOS 13 上呈现为 Times New Roman

我有一些UILabel默认的系统字体。但是当我在装有 iOS 13.1 的 iPad 或 iPhone 上安装我的应用程序时,字体会变成类似Times New Roman! 为什么会发生这种情况?我确定标签的文本是普通的,字体是System. 我该如何解决这个问题?

PS:我已经从苹果网站下载了所有的SF字体,仍然没有运气!

xcode ios

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

从Xcode恢复已删除的文件

我只是不小心从Xcode proj中删除了一些文件,但我确定我按下了remove reference only按钮,但是我的所有图像都已从我的项目中删除了,我无法在我的硬盘上找到它们,无论如何要恢复这些图像?垃圾中没有图像的迹象!

iphone sdk xcode ipad ios

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

每隔30分钟发出重复间隔的问题

我试图每30分钟重复一次本地通知,但我的代码不能正常工作......如果你帮助我找到解决方案,我将不胜感激,这是我的代码:

UILocalNotification *reminderNote = [[UILocalNotification alloc]init];
reminderNote.fireDate = [NSDate dateWithTimeIntervalSinceNow:60 * 30];
reminderNote.repeatInterval = NSHourCalendarUnit;
reminderNote.alertBody = @"some text";
reminderNote.alertAction = @"View";
reminderNote.soundName = @"sound.aif";
[[UIApplication sharedApplication] scheduleLocalNotification:reminderNote];
Run Code Online (Sandbox Code Playgroud)

iphone xcode ios uilocalnotification

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

用Instagram打开图像

嗨我需要在Instagram中导入我编辑过的图像,比如PhotoStudio:

在此输入图像描述

我使用以下代码捕获了我的图像:

    UIGraphicsBeginImageContextWithOptions(self.captureView.bounds.size, self.captureView.opaque, 0.0);
    [self.captureView.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage * screenshot = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();
Run Code Online (Sandbox Code Playgroud)

然后我需要screenShot用Instagram 打开它:


编辑:

我实现这样的方法:

    UIGraphicsBeginImageContextWithOptions(self.captureView.bounds.size, self.captureView.opaque, 0.0);
    [self.captureView.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage * screenshot = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    NSURL *igImageHookFile = [[NSURL alloc] initWithString:[[NSString alloc] initWithFormat:@"file://%@", screenshot]];

    docFile.UTI = @"com.instagram.photo";
    [self setupDocumentControllerWithURL:igImageHookFile];

    NSURL *instagramURL = [NSURL URLWithString:@"instagram://media?id=MEDIA_ID"];
    if ([[UIApplication sharedApplication] canOpenURL:instagramURL]) {
        [[UIApplication sharedApplication] openURL:instagramURL];
    }

    else {   
        NSLog(@"No Instagram Found");
    }
}
Run Code Online (Sandbox Code Playgroud)

但是我收到了这个输出:

2012-05-05 21:55:36.842 InstantFrame[855:707] *** Assertion failure in -[UIDocumentInteractionController setURL:], /SourceCache/UIKit/UIKit-1914.84/UIDocumentInteractionController.m:1094
2012-05-05 21:55:36.848 InstantFrame[855:707] …
Run Code Online (Sandbox Code Playgroud)

iphone xcode objective-c ipad ios

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

在tvOS中呈现视图控制器

我试图在tvOS应用程序中呈现一个视图控制器,但所包含的代码片段都没有.我错过了什么?

代码1:

 DinoViewController *dinoVC = [[DinoViewController alloc]init];
        dinoVC.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
        [self presentViewController:dinoVC animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)

代码2:

   UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
        DinoViewController *dinoVC = [storyboard instantiateInitialViewController];
        dinoVC.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
        [self presentViewController:dinoVC animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)

objective-c tvos

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

Xcode 8.3.2 Clang错误

我正在尝试更新我的一个项目,当我打开它时,我执行了验证设置,但是当我尝试构建它时,我只是面对这个错误:

Apple Mach-O链接器错误组:clang:错误:链接器命令失败,退出代码为1(使用-v查看调用)

没有更多的信息,我没有使用cocoapods或任何外部框架.我只是到处搜索并做了任何可能的解决方案,例如:

  • 清洁并运行
  • 搜索重复文件
  • 检查导入的头文件
  • 删除xxxTest
  • Checked Build Active架构
  • 验证设置
  • 检查丢失的框架
  • 重启mac
  • 更改了iOS部署目标
  • 禁用bitcode

等等...

有什么可以解决这个问题吗?

iphone xcode ios

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