小编Jac*_*ack的帖子

如何将UIButton的标题设置为左对齐?

我需要从a的左侧显示电子邮件地址UIButton,但它位于中心.

有没有办法将对齐设置为左侧UIButton

这是我目前的代码:

UIButton* emailBtn = [[UIButton alloc] initWithFrame:CGRectMake(5,30,250,height+15)];
emailBtn.backgroundColor = [UIColor clearColor];
[emailBtn setTitle:obj2.customerEmail forState:UIControlStateNormal];
emailBtn.titleLabel.font = [UIFont systemFontOfSize:12.5];
[emailBtn setTitleColor:[[[UIColor alloc]initWithRed:0.121 green:0.472 blue:0.823 alpha:1]autorelease] forState:UIControlStateNormal];
[emailBtn addTarget:self action:@selector(emailAction:) forControlEvents:UIControlEventTouchUpInside];
[elementView addSubview:emailBtn];
[emailBtn release];
Run Code Online (Sandbox Code Playgroud)

objective-c uibutton

458
推荐指数
9
解决办法
20万
查看次数

UITextField的文本插入?

我想插页的文字UITextField.

这可能吗?

cocoa-touch uitextfield ios

402
推荐指数
20
解决办法
19万
查看次数

无法实例化名为MKMapView的类

我可能在这里做了一些非常愚蠢的事情,因为我之前已经完成了它并且现在......

创建了一个新的iPad项目,在详细信息视图中我添加了一个MKMapView,将MapKit.framework添加到项目中,将属性/等添加到标题中.去运行项目并获得SIGABRT

****由于未捕获的异常'NSInvalidUnarchiveOperationException'而终止应用程序,原因:'无法实例化名为MKMapView的类'**

我找到了http://mithin.in/2009/06/22/using-iphone-sdk-mapkit-framework-a-tutorial/,但就像我说的那样,我已经添加了框架.我错过了什么?

mkmapview ipad ios

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

NSInvalidUnarchiveOperationException:无法实例化名为NSLayoutConstraint的类

我对此很新.我一步一步地关注了Apple项目"HelloWorld"的Apple教程.我在iPhone 5.0模拟器中运行它并崩溃了:

2012-11-02 14:46:06.782 HelloWorld [9880:c07] *由于未捕获的异常'NSInvalidUnarchiveOperationException'终止应用程序,原因:'无法实例化名为NSLayoutConstraint的类'*首先抛出调用堆栈:(0x14a2052 0xea2d0a 0x144aa78 0x144a9e9 0x32f7d7 0x32f9af 0x32f6b7 0x23036d 0xd7e2c 0xd83a9 0xd85cb 0x38a73 0x38ce2 0x38ea8 0x3fd9a 0x10be6 0x118a6 0x20743 0x211f8 0x14aa9 0x138cfa9 0x14761c5 0x13db022 0x13d990a 0x13d8db4 0x13d8ccb 0x112a7 0x12a9b 0x1fed 0x1f15 0x1)终止调用抛出异常(lldb)

有人可以告诉我出了什么问题吗?我正在使用Xcode 4.5.

objective-c ios autolayout

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

Cocoapods:无法连接到GitHub以更新CocoaPods/Specs规格repo

运行时pod repo update会生成以下错误:

Updating spec repo `master`
[!] Failed to connect to GitHub to update the CocoaPods/Specs specs repo - Please check if you are offline, or that GitHub is down
Run Code Online (Sandbox Code Playgroud)


使用cocoapods 1.0.1

我也知道这一点:主要规格回购率限制验尸.


在调用中添加--verbose标志会显示ruby调用堆栈:

.rvm/gems/ruby-2.3.0/gems/cocoapods-core-1.0.1/lib/cocoapods-core/github.rb:100:in `modified_since_commit'
.rvm/gems/ruby-2.3.0/gems/cocoapods-core-1.0.1/lib/cocoapods-core/master_source.rb:32:in `requires_update?'
.rvm/gems/ruby-2.3.0/gems/cocoapods-core-1.0.1/lib/cocoapods-core/master_source.rb:14:in `update'
.rvm/gems/ruby-2.3.0/gems/cocoapods-1.0.1/lib/cocoapods/sources_manager.rb:88:in `block (2 levels) in update'
.rvm/gems/ruby-2.3.0/gems/cocoapods-1.0.1/lib/cocoapods/user_interface.rb:63:in `section'
.rvm/gems/ruby-2.3.0/gems/cocoapods-1.0.1/lib/cocoapods/sources_manager.rb:87:in `block in update'
.rvm/gems/ruby-2.3.0/gems/cocoapods-1.0.1/lib/cocoapods/sources_manager.rb:86:in `each'
.rvm/gems/ruby-2.3.0/gems/cocoapods-1.0.1/lib/cocoapods/sources_manager.rb:86:in `update'
.rvm/gems/ruby-2.3.0/gems/cocoapods-1.0.1/lib/cocoapods/command/repo/update.rb:23:in `run'
.rvm/gems/ruby-2.3.0/gems/claide-1.0.0/lib/claide/command.rb:334:in `run'
.rvm/gems/ruby-2.3.0/gems/cocoapods-1.0.1/lib/cocoapods/command.rb:50:in `run'
.rvm/gems/ruby-2.3.0/gems/cocoapods-1.0.1/bin/pod:55:in `<top (required)>'
.rvm/gems/ruby-2.3.0/bin/pod:23:in `load'
.rvm/gems/ruby-2.3.0/bin/pod:23:in `<main>'
.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `eval'
.rvm/gems/ruby-2.3.0/bin/ruby_executable_hooks:15:in `<main>'
Run Code Online (Sandbox Code Playgroud)


找不到任何解决方法,也无法运行该项目.

xcode ios cocoapods cocoapods-1.0.1

136
推荐指数
9
解决办法
6万
查看次数

致命错误:在解包可选值时意外发现nil

UICollectionView在Swift 中使用了一个,但是当我尝试更改单元格标签的文本时,我得到了.

    func collectionView(collectionView: UICollectionView!, numberOfItemsInSection section: Int) -> Int
{
    return 5
}

func collectionView(collectionView: UICollectionView!, cellForItemAtIndexPath indexPath: NSIndexPath!) -> UICollectionViewCell!
{
    var cell = collectionView.dequeueReusableCellWithReuseIdentifier("title", forIndexPath: indexPath) as TitleCollectionViewCell
    // Next line: fatal error: unexpectedly found nil while unwrapping an Optional value
    cell.labelTitle.text = "This is a title"
    return cell
}
Run Code Online (Sandbox Code Playgroud)

有谁知道这个?

控制台上警告的屏幕截图

ios uicollectionview swift

125
推荐指数
6
解决办法
25万
查看次数

Safari中的Swift Open Link

我目前正在我的应用程序中打开链接WebView,但我正在寻找一个选项来在Safari中打开链接.

safari webview swift

125
推荐指数
6
解决办法
9万
查看次数

UIButton图像+文本IOS

我需要UIButton图像和文字.图像应位于顶部,文本位于图像下方,均应可点击.

iphone uibutton ipad ios

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

Swift中的日期格式

我如何从日期转换此日期时间?

由此:2016-02-29 12:24:26发布
于:2016年2月29日

到目前为止,这是我的代码,它返回一个nil值:

let dateFormatter = NSDateFormatter()
dateFormatter.dateFormat = "MM-dd-yyyy"
dateFormatter.timeZone = NSTimeZone(name: "UTC")
let date: NSDate? = dateFormatter.dateFromString("2016-02-29 12:24:26")
print(date)
Run Code Online (Sandbox Code Playgroud)

nsdate nsdateformatter ios swift

115
推荐指数
15
解决办法
19万
查看次数

检测到约束模糊地表示高度为零的情况

在我运行包含tableview单元格的应用程序后更新到Xcode 6.1 beta 2后,调试助手说:

Warning once only: Detected a case where constraints ambiguously suggest a height of zero for a tableview cell's content view. We're considering the collapse unintentional and using standard height instead.
Run Code Online (Sandbox Code Playgroud)

之前,当我在这个项目上使用Xcode 5时,我会遇到一些错误,但是自从我升级后它们已经消失了.我现在没有其他错误或警告.我已经尝试调整所有tableview单元格的大小,并尝试使用标准高度,但我仍然得到相同的警告:

Warning once only: Detected a case where constraints ambiguously suggest a height of zero for a tableview cell's content view. We're considering the collapse unintentional and using standard height instead.
Run Code Online (Sandbox Code Playgroud)

我也阅读了所有类似的主题,但他们的解决方案都没有帮助.当我使用模拟器测试应用程序时,应用程序运行正常,除了应该在tableView单元格中的图片不存在.

xcode objective-c uitableview ios swift

109
推荐指数
8
解决办法
6万
查看次数