标签: ios8

故事板中的自适应segue Xcode 6.推送是否被弃用?

默认情况下,Xcode 6界面构建器具有新的复选框"使用大小类".它使视图自适应. 在此输入图像描述

当我尝试在我的故事板中的2个视图之间制作segue时,我有了新的选择: 在此输入图像描述

相反旧:

在此输入图像描述

现在我们有"显示"和"呈现模态"而不是"推"和"模态".旧选项标记为已弃用.我选择了"show"选项,因为在segue设置中它称为"show(例如push)

在此输入图像描述

但它没有推动.Segue动画看起来像从底部滑动(模态),导航栏消失.

问题是:如何让"show"像push一样工作?是否可以或者我应该使用"推(弃用)"代替?我在哪里可以找到有关新型segue的任何信息?我在iOS8开发人员库中找到的唯一一件事是Storyboards帮助您设计用户界面,但没有关于"show"segue的信息.

UPDATE

我试图创建新项目,"show"真的像"推"一样工作.我认为我的项目中的问题可能是因为我重复使用导航控制器这样的代码,但我不知道如何解决它.

if ( [segue isKindOfClass: [SWRevealViewControllerSegue class]] ) {
    SWRevealViewControllerSegue *swSegue = (SWRevealViewControllerSegue*) segue;

    swSegue.performBlock = ^(SWRevealViewControllerSegue* rvc_segue, UIViewController* svc, UIViewController* dvc) {

        UINavigationController* navController = (UINavigationController*)self.revealViewController.frontViewController;
        [navController setViewControllers: @[dvc] animated: NO ];
        [self.revealViewController setFrontViewPosition: FrontViewPositionLeft animated: YES];
    };

}
Run Code Online (Sandbox Code Playgroud)

之后我尝试在MainViewController之后推送NewViewController 在此输入图像描述

更新2:

我似乎只是iOS 7,iOS 7.1问题.

push storyboard xcode6 ios8

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

WKWebView无法在iOS 8下加载本地文件

对于以前的iOS测试版8,负荷(束)本地web应用程序,它都为正常工作UIWebViewWKWebView,我甚至移植使用新的网页游戏WKWebViewAPI.

var url = NSURL(fileURLWithPath:NSBundle.mainBundle().pathForResource("car", ofType:"html"))

webView = WKWebView(frame:view.frame)
webView!.loadRequest(NSURLRequest(URL:url))

view.addSubview(webView)
Run Code Online (Sandbox Code Playgroud)

但在测试版4中,我只是得到了一个空白的白色屏幕(UIWebView仍在工作),看起来没有任何内容被加载或执行.我在日志中看到一个错误:

无法为其创建沙箱扩展 /

有没有帮助引导我走向正确的方向?谢谢!

ios swift ios8 wkwebview

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

要求用户权限在iOS 8中接收UILocalNotifications

我在App Delegate中设置了本地通知使用此方法:

- (void)applicationDidEnterBackground:(UIApplication *)application
{
    UILocalNotification *notification = [[UILocalNotification alloc]init];
    [notification setAlertBody:@"Watch the Latest Episode of CCA-TV"];
    [notification setFireDate:[NSDate dateWithTimeIntervalSinceNow:5]];
    [notification setTimeZone:[NSTimeZone defaultTimeZone]];
    [application setScheduledLocalNotifications:[NSArray arrayWithObject:notification]];
}
Run Code Online (Sandbox Code Playgroud)

当我运行应用程序然后退出它时,我收到一条错误消息:

2014-06-07 11:14:16.663 CCA-TV [735:149070] 试图安排本地通知 {开火日期= 2014年6月7日星期六太平洋夏令时间11:14:21,时区= America/Los_Angeles (PDT)偏移-25200(日光),重复间隔= 0,重复计数= UILocalNotificationInfiniteRepeatCount,下一个开火日期= 2014年6月7日星期六太平洋夏令时间11:14:21,用户信息=(null)} 带警报但尚未收到用户显示警报的许可

如何获得显示警报的必要权限?

notifications cocoa-touch ios uilocalnotification ios8

115
推荐指数
4
解决办法
6万
查看次数

如何在iOS 8中正确呈现popover

我正在尝试将UIPopoverView添加到我的Swift iOS 8应用程序,但我无法访问PopoverContentSize属性,因为popover没有显示正确的形状.我的代码:

var popover: UIPopoverController? = nil 

    func addCategory() {

    var newCategory = storyboard.instantiateViewControllerWithIdentifier("NewCategory") as UIViewController
    var nav = UINavigationController(rootViewController: newCategory)
    popover = UIPopoverController(contentViewController: nav)
    popover!.setPopoverContentSize(CGSizeMake(550, 600), animated: true)
    popover!.delegate = self
    popover!.presentPopoverFromBarButtonItem(self.navigationItem.rightBarButtonItem, permittedArrowDirections: UIPopoverArrowDirection.Any, animated: true)
}
Run Code Online (Sandbox Code Playgroud)

输出:

在此输入图像描述

当我通过UIPopoverPresentationController做同样的事情时,我仍然没有完成它.这是我的代码:

func addCategory() {

    var popoverContent = self.storyboard.instantiateViewControllerWithIdentifier("NewCategory") as UIViewController
    var nav = UINavigationController(rootViewController: popoverContent)
    nav.modalPresentationStyle = UIModalPresentationStyle.Popover
    var popover = nav.popoverPresentationController as UIPopoverPresentationController
    popover.delegate = self
    popover.popoverContentSize = CGSizeMake(1000, 300)
    popover.sourceView = self.view
    popover.sourceRect = CGRectMake(100,100,0,0)

    self.presentViewController(nav, animated: true, …
Run Code Online (Sandbox Code Playgroud)

uipopovercontroller ios uipopover swift ios8

115
推荐指数
6
解决办法
17万
查看次数

我可以设置WKWebView使用的cookie吗?

我正在尝试将现有的应用程序从UIWebView切换到WKWebView.当前应用程序管理Web视图之外的用户登录/会话,并将身份验证所需的cookie设置为NSHTTPCookieStore.不幸的是,新的WKWebView不使用NSHTTPCookieStorage中的cookie.还有另一种方法来实现这一目标吗?

cookies uiwebview ios ios8 wkwebview

111
推荐指数
10
解决办法
11万
查看次数

iOS 8上的企业应用更新分发

我有一个企业应用程序,我通过itmsURL 分发:

itms-services://?action=download-manifest&url=itms-services://?action=download-manifest&url=https://$MY_PLIST_URL.plist
Run Code Online (Sandbox Code Playgroud)

在iOS 7上,下载和更新都可以正常工作.但是,在iOS 8上,我收到错误:

LoadExternalDownloadManifestOperation: Ignore manifest download, already have bundleID: com.mycom.MyApp
Run Code Online (Sandbox Code Playgroud)

在我的plist中,我有

<key>bundle-identifier</key>
<string>com.mycom.MyApp</string>
<key>bundle-version</key>
<string>0.2.2</string>
Run Code Online (Sandbox Code Playgroud)

在iOS 8上的应用程序中,我运行的是0.2.1版本

xcode ios enterprise-distribution ios8

110
推荐指数
6
解决办法
5万
查看次数

键盘iPhone-Portrait-NumberPad找不到支持类型4的键盘; 使用3876877096_Portrait_iPhone-Simple-Pad_Default

我已经为iPhone和SDK下载了iOS 8 Gold Master.

我测试了应用程序,它工作正常,除了一件事.

我有一个文本字段,如果用户想要键入内容,则会出现数字键盘,此外,当键盘显示时,自定义按钮会添加到空白区域.

- (void)addButtonToKeyboard
{
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
    {
        // create custom button
        UIButton * doneButton = [UIButton buttonWithType:UIButtonTypeCustom];
        doneButton.frame = CGRectMake(-2, 163, 106, 53);
        doneButton.adjustsImageWhenHighlighted = NO;
        [doneButton setImage:[UIImage imageNamed:@"DoneUp.png"] forState:UIControlStateNormal];
        [doneButton setImage:[UIImage imageNamed:@"DoneDown.png"] forState:UIControlStateHighlighted];
        [doneButton addTarget:self action:@selector(saveNewLead:) forControlEvents:UIControlEventTouchUpInside];

        // locate keyboard view
        UIWindow * tempWindow = [[[UIApplication sharedApplication] windows]objectAtIndex:1];
        UIView* keyboard;
        for(int i=0; i<[tempWindow.subviews count]; i++) 
        {
            keyboard = [tempWindow.subviews objectAtIndex:i];

            // keyboard view found; add the custom button to it
            if ([[[UIDevice …
Run Code Online (Sandbox Code Playgroud)

iphone ios8

110
推荐指数
9
解决办法
11万
查看次数

UIAlertController自定义字体,大小,颜色

我正在使用新的UIAlertController来显示警报.我有这个代码:

// nil titles break alert interface on iOS 8.0, so we'll be using empty strings
UIAlertController *alert = [UIAlertController alertControllerWithTitle: title == nil ? @"": title message: message preferredStyle: UIAlertControllerStyleAlert];


UIAlertAction *defaultAction = [UIAlertAction actionWithTitle: cancelButtonTitle style: UIAlertActionStyleCancel handler: nil];

[alert addAction: defaultAction];

UIViewController *rootViewController = [UIApplication sharedApplication].keyWindow.rootViewController;
[rootViewController presentViewController:alert animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)

现在我想更改标题和消息字体,颜色,大小等.什么是最好的方法呢?

编辑: 我应该插入整个代码.我为UIView创建了一个类别,我可以为iOS版本显示正确的警报.

@implementation UIView (AlertCompatibility)

+( void )showSimpleAlertWithTitle:( NSString * )title
                          message:( NSString * )message
                cancelButtonTitle:( NSString * )cancelButtonTitle
{
    float iOSVersion = [[UIDevice currentDevice].systemVersion floatValue]; …
Run Code Online (Sandbox Code Playgroud)

objective-c uialertview ios ios8 uialertcontroller

109
推荐指数
13
解决办法
16万
查看次数

UITableView动态单元格高度仅在某些滚动后才能正确显示

我有一个使用自动布局在故事板中定义UITableView的自UITableViewCell定义.细胞有几条多线UILabels.

UITableView出现要正确计算单元格高度,但在最初的几个细胞高度不正确的标签之间的分歧.滚动一下后,一切都按预期工作(即使是最初不正确的单元格).

- (void)viewDidLoad {
    [super viewDidLoad]
    // ...
    self.tableView.rowHeight = UITableViewAutomaticDimension;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    TableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"TestCell"];
    // ...
    // Set label.text for variable length string.
    return cell;
}
Run Code Online (Sandbox Code Playgroud)

有什么我可能会遗漏,导致自动布局在前几次无法完成其工作吗?

我已经创建了一个演示此行为的示例项目.

示例项目:首次加载时示例项目的表格视图顶部. 示例项目:向下滚动和备份后的相同单元格.

uitableview ios autolayout ios8 ios-autolayout

107
推荐指数
9
解决办法
5万
查看次数

XCode6大小类中的自定义字体大小调整与自定义字体无法正常工作

Xcode 6有一个新功能,可以在故事板中根据当前设备配置的大小类自动设置UILabel,UITextField和UIButton中的字体和字体大小.例如,您可以将UILabel设置为在"任何宽度,紧凑高度"(例如在横向上的iPhone上)配置上使用字体大小12,在"常规宽度,常规高度"配置(例如在iPad上)上使用大小18.更多信息请点击这里:

https://developer.apple.com/library/content/documentation/UserExperience/Conceptual/AutolayoutPG/Size-ClassSpecificLayout.html

这在理论上是一个非常好的功能,因为它可以使得不必根据设备配置以编程方式在UI功能上设置不同的字体.现在,我有一些条件代码根据设备类型设置字体,但显然这意味着我必须在整个应用程序的各个地方以编程方式设置字体.所以我最初对此功能感到非常兴奋,但我发现它在实际使用中存在严重问题(可能是一个bug).请注意,我正在构建针对SDK 8并设置iOS 8的最低部署目标,因此这与与旧版iOS的兼容性无关.

问题是:如果我为不同的大小类设置不同的字体大小,并使用iOS提供的"系统"字体,一切都按预期工作,字体大小根据大小类更改.如果我使用我的应用程序提供的自定义字体(是的,我在应用程序包中正确设置,因为它以编程方式工作)并将自定义字体设置为XCode 6故事板中的标签,这也可以按预期工作.但是当我尝试为不同大小的类使用不同大小的自定义字体时,在故事板中,它突然不起作用.配置的唯一区别是我选择的字体(自定义字体与系统字体).相反,所有字体都显示在设备和模拟器上作为默认大小的默认系统字体,无论大小等级(我通过调试器验证它是用系统字体替换故事板中指定的实际字体) .所以基本上,自定义字体的大小类功能似乎已被破坏.另外,有趣的是,自定义字体实际上在视图控制器的XCode 6"预览"窗格中正确显示和调整大小:只有在实际的iOS系统上运行它才停止工作(这让我觉得我正在配置它正确).

我尝试了多种不同的自定义字体,它似乎不适用于任何一种,但如果我使用"系统",它总是有效.

无论如何,还有其他人在Xcode 6中看到过这个问题吗?关于这是否是iOS 8,Xcode中的错误或者我做错了什么的任何想法?我发现,我发现的唯一解决方法是继续以编程方式设置字体,就像我已经为大约3个版本的iOS一样,因为这确实有效.但我希望能够使用此功能,如果我可以使用自定义字体.我们的设计不接受使用System字体.


附加信息:从Xcode 8.0开始,修复了错误.

interface-builder ios xcode6 ios8 size-classes

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