小编mxb*_*mxb的帖子

Swift相当于MIN和MAX宏

在C/Objective-C中,可以使用MIN和MAX宏找到两个数字之间的最小值和最大值.Swift不支持宏,似乎语言/库中没有等价物.每个人都应该有一个定制的解决方案,也许基于这样的仿制药进入一个

generics swift

92
推荐指数
4
解决办法
5万
查看次数

Xcode6:使用Objective-C进行IBDesignable和IBInspectable

我有一个Objective-C UI组件,我想在Interface Builder中使用Xcode 6进行检查.Swift具有@IBDesignable@IBInspectable声明属性.它们是否也可用于Objective-C?它们是如何使用的?

objective-c swift xcode6

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

如何使用IBDesignable UIImageView在prepareForInterfaceBuilder中加载图像

我想在IB设计中加载样本图像,UIImageView在编辑界面时在Interface Builder中显示.以下代码不起作用,因为IB中的视图占位符保持为空(视图区域仅包含UIImageView文本):

@IBDesignable
class TestImageView : UIImageView
{
    override func prepareForInterfaceBuilder() {
        //let bundle = NSBundle.mainBundle()
        let bundle = NSBundle(forClass: nil)
        let imagePath = bundle.pathForResource("Test", ofType: "jpg")
        self.image = UIImage(contentsOfFile: imagePath)
    }
}
Run Code Online (Sandbox Code Playgroud)

注意:

  • 在IB中,视图的Custom Class类是正确的(TestImageView)
  • Test.jpg存在于项目中(如果我手动设置UIImageViewIB中图像属性的图像显示).
  • 我尝试了两种不同的方法来获取代码中的包

这是用Xcode 6 beta 3测试的.

更新:在这两种情况下,我获得的捆绑路径是"/Applications/Temporary/Xcode6-Beta3.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Xcode/Overlays".在该路径中,图像显然不存在.

uiimageview ios swift

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

将modalPresentationStyle设置为自定义会导致MFMailComposeViewController中的状态栏颜色错误

我有一个简单的控制器,显示另一个具有自定义转换的控制器.我用一个坚固的导航栏:

self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
self.navigationController.navigationBar.barTintColor = [UIColor purpleColor];
self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
Run Code Online (Sandbox Code Playgroud)

这是第二个控制器: 在此输入图像描述

当我MFMailComposeViewController在子控制器中打开一个状态栏时,状态栏是白色的白色(这也附加UIActivityViewController): 在此输入图像描述

事实证明,这与设置modalPresentationStyleUIModalPresentationCustom:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    UIViewController *controller = (UIViewController*)segue.destinationViewController;

    // this line cause the bug
    //controller.modalPresentationStyle = UIModalPresentationCustom;

    controller.transitioningDelegate = self;
}
Run Code Online (Sandbox Code Playgroud)

如果controller.modalPresentationStyle保持不变,状态栏颜色是正确的.而且,这个属性似乎不会干扰自定义转换.

我在这里错过了一些东西?为什么会modalPresentationStyle影响系统控制器中的状态栏类型?这可能是个错误吗?

完整代码在这里https://github.com/mbigatti/StatusBarTest

objective-c uiviewcontroller ios

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