小编Kru*_*nal的帖子

UILabel线间距

我想设置的行间距在UILabel由Mike斯拉斯基指定位置.它适用于我从Storyboard指定的文本.当我尝试设置UILabel.text代码时,它将恢复为默认行间距.有人可以帮我理解如何:

  1. 使其不会恢复为默认值,并使用我在Storyboard上指定的设置或

  2. 在代码中设置值.

我已经看过很多关于使用NSAttribute和的例子NSParagraph,但由于现在可以设置在故事板中,我希望它们可能是一个更简单的答案.非常感谢您的帮助!

我设置了"高度倍数",如上面的链接所示,我唯一的代码如下:

import UIKit

class ViewController: UIViewController {

    @IBOutlet weak var textView: UILabel!

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.

        textView.text = "Some example text"
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

}
Run Code Online (Sandbox Code Playgroud)

如果我删除textView.text行,它会正确显示,否则会重新设置为默认行间距(或高度倍数).

xcode objective-c uilabel ios swift

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

如何从我的应用启用/禁用推送通知

我正在使用具有推送通知属性的应用程序.我应该我的应用程序中启用/禁用推送通知权限,而无需转到iPhone设置.

有没有办法实现呢?

我搜索了很多,但我找不到任何正确的方法来实现它.

有帮助吗?

objective-c push-notification ios swift remote-notifications

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

如何以编程方式在iOS中获得较高的导航栏

keyboardwillshown当键盘隐藏时,我必须将视图向上移动到正常位置

实际上,我在viewdidload方法上使用了以下代码:

override func viewDidLoad() { 

    NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("keyboardWillShow:"), name: UIKeyboardWillShowNotification, object: nil)
    NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("keyboardWillHide:"), name: UIKeyboardWillHideNotification, object: nil) 

}
Run Code Online (Sandbox Code Playgroud)

这是我用来上下移动的方法

func keyboardWillShow(notification:NSNotification){ 

    print("keyboardwillshow")
    let keyboardSize = (notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as? NSValue)?.CGRectValue()

    self.view.frame = CGRectMake(0.0, -keyboardSize!.size.height + (self.navigationController?.navigationBar.frame.size.height)! + 20 , self.view.frame.size.width, self.view.frame.size.height )  

}

func keyboardWillHide(notification:NSNotification){

    self.view.frame = CGRectMake(0.0,(self.navigationController?.navigationBar.frame.size.height)!, self.view.frame.size.width, self.view.frame.size.height)
//  self.view.frame.origin.y += 350

}
Run Code Online (Sandbox Code Playgroud)

当我运行该程序时,它将显示一个运行时错误,

意外发现展开时发现零

请帮我解决这个问题。

xcode objective-c uinavigationbar ios swift

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

使用动画更改状态栏样式

由于UIApplication.shared.setStatusBarStyle(.default, animated: true)从IOS9弃用是有可能改变的状态栏风格的动画push?我在文档中找不到任何描述.

objective-c statusbar ios uistatusbar swift

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

UILabel - 如何在Swift 3中的行之间添加空格

我有UILabel的章节信息(多行文字),我想在行之间添加一些空格,类似于这个图像.

这个图片

请帮我做.我试图查看苹果开发者关于标签和行间距的所有文档,但可以找到.

uilabel ios swift nsparagraphstyle line-spacing

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

有没有办法只在 iOS 模拟器中应用更改而不重建整个应用程序?

我问是因为这是 android studio 的一个功能,并且想知道 xcode 或外部事物是否有类似的东西?

xcode ios ios-simulator xcode9

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

UIImagePickerController 编辑的图像在 iPad 中检索错误的图像

我必须UIImagePickerController从照片库中选择/挑选图像。我已经允许 UIImagePickerController 编辑(选定的)图像(图像的裁剪方框),这在 iPhone 上运行良好,但 iPad 无法提供正确编辑(裁剪)的图像。

我尝试了以下建议但找不到解决方案:
iPad iOS7 - UIPopoverController 中的 UIImagePickerController has wrong preview image

这是我尝试过的代码:

let imagePicker = UIImagePickerController()
imagePicker.allowsEditing = true

// Update (zoom) visibility of image using pinch gesture & retrieve image using delegate - didFinishPickingMediaWithInfo

//------------------------------------------
 func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {


     if let pickedImage = info[UIImagePickerControllerEditedImage] as? UIImage {
         // Wrong image - retrieves image different than actual visible in the editing window of picker view. …
Run Code Online (Sandbox Code Playgroud)

uiimagepickercontroller uiimage ipad ios swift

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

如何获得透明的状态栏,如下图所示?

在此处输入图片说明

我需要一个透明的状态栏,如下图所示。

我试过了

UIView *statusBar = [[[UIApplication sharedApplication] valueForKey:@"statusBarWindow"] valueForKey:@"statusBar"];

if ([statusBar respondsToSelector:@selector(setBackgroundColor:)]) {
    statusBar.backgroundColor = [UIColor clearColor];
}
Run Code Online (Sandbox Code Playgroud)

但这基本上给出了与UIStatusBarStyleLightContent相同的结果。

uinavigationbar uinavigationcontroller ios uistatusbar swift

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

如何在 swift 3 中动态隐藏 tabBarController 中的选项卡

我正在使用 UITabBarController 并使用情节提要中的关系 Segue 添加选项卡。

如何根据登录用户角色隐藏特定选项卡?

uitabbarcontroller uitabbar ios swift ios11

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

应用转移后的 iOS 配置

我正在我的个人帐户下开发一个 iOS 应用程序,到目前为止使用 Xcode 的自动签名功能进行应用程序配置。我现在将该应用程序转移到我不属于的另一个组织,但他们希望我继续开发该应用程序。他们创建了我的个人帐户,该应用程序曾经是该特定应用程序帐户中的“应用程序管理员”。

现在我想提交应用程序更新,但自动签名不再起作用。我收到错误“无法创建配置文件:应用 ID 无法注册到您的开发团队”,这是可以理解的,因为应用 ID 已移至组织的帐户。我无法访问该组织的帐户,因为那里还有其他应用程序。

我确定在这种情况下必须有一种方法可以继续为他们的帐户上传应用程序更新?

xcode development-environment ios ios-provisioning apple-developer

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