我可以通过这种方式在Xcode 6中创建快照,如下图所示:
但是在Xcode 7中它不可用,你可以在下面的图片中看到:
而且control-command-S也行不通.
现在有人能告诉我如何使用Xcode 7创建快照?
我是新手,Swift我正在制作一个简单的计算器,我不想检测按下的按钮,我的代码在下面.
@IBAction func ButtonTapped(TheButton : UIButton){
println(TheButton.titleLabel.text)
}
Run Code Online (Sandbox Code Playgroud)
但它显示我的错误 "UILabel? Does not have a member a named text"
它告诉我修改这样的代码
println(TheButton.titleLabel?.text)
Run Code Online (Sandbox Code Playgroud)
这个Prints Optional("1")(1是我的按钮名称)
所以任何人都可以帮助我为什么会发生这种情况,如何在没有可选项的情况下打印我的按钮名称?
我有一个简单的数组,如:
var cellOrder = [1,2,3,4]
Run Code Online (Sandbox Code Playgroud)
我想交换元素,比如假设第二个元素与第一个元素.
结果将是:
[2,1,3,4]
Run Code Online (Sandbox Code Playgroud)
我知道我们可以用exchangeObjectAtIndex用NSMutableArray,但我想用快捷阵列.有没有办法用swift [Int]数组做同样的事情?
简而言之,我想创建一个@IBInspectable属性,允许您在Storyboard中从下拉菜单中选择事物列表.此外,如果有办法创建分隔线并更好地组织,IBInspectables我想知道这是否也可行.在我的示例中,我想为电话号码创建正则表达式字符串,以便当我转到故事板时,我可以在下拉菜单中选择" 电话号码 "项,而不是输入正则表达式字符串.
目前我已经分类了一个,TextField所以我可以添加更多IBInspectables像正则表达式(你可以在图片中看到).因此,这就是我对我的子类所拥有的UITextField:
@IBDesignable public class FRM_TextField: UITextField {
@IBInspectable public var regex : String?
public var isValid : Bool{
if let unwrappedRegex = regex{
let applied_regex_expression = NSRegularExpression.regularExpressionWithPattern(unwrappedRegex, options: nil, error: nil)
let numberOfMatches = applied_regex_expression?.numberOfMatchesInString(text, options: nil, range: NSMakeRange(0, countElements(text)))
if(numberOfMatches > 0 ){
return true
}else{
return false
}
}
return false
}
public required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
public override init(){
super.init(); …Run Code Online (Sandbox Code Playgroud) 我正在创建一个从网站获取信息的天气应用程序.我最后一次编码(昨晚)一切都很好,我能够编译并运行模拟器,没有任何错误.就在今天,当我启动同一个项目而没有改变任何东西时,我得到了"Apple Mach-O Linker Error".你能帮忙吗?
以下是错误的详细信息:
Ld /Users/Allister/Library/Developer/Xcode/DerivedData/Haze_Meter-dkjjcmjehyitmcbhkcbujnsrhwpu/Build/Products/Debug-iphonesimulator/Haze\ Meter.app/Haze\ Meter normal x86_64
cd "/Users/Allister/Documents/XCODE/Haze Meter"
export IPHONEOS_DEPLOYMENT_TARGET=8.3
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.3.sdk -L/Users/Allister/Library/Developer/Xcode/DerivedData/Haze_Meter-dkjjcmjehyitmcbhkcbujnsrhwpu/Build/Products/Debug-iphonesimulator -F/Users/Allister/Library/Developer/Xcode/DerivedData/Haze_Meter-dkjjcmjehyitmcbhkcbujnsrhwpu/Build/Products/Debug-iphonesimulator -filelist /Users/Allister/Library/Developer/Xcode/DerivedData/Haze_Meter-dkjjcmjehyitmcbhkcbujnsrhwpu/Build/Intermediates/Haze\ Meter.build/Debug-iphonesimulator/Haze\ Meter.build/Objects-normal/x86_64/Haze\ Meter.LinkFileList -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -objc_abi_version -Xlinker 2 -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphonesimulator -Xlinker -add_ast_path -Xlinker /Users/Allister/Library/Developer/Xcode/DerivedData/Haze_Meter-dkjjcmjehyitmcbhkcbujnsrhwpu/Build/Intermediates/Haze\ Meter.build/Debug-iphonesimulator/Haze\ Meter.build/Objects-normal/x86_64/Haze_Meter.swiftmodule -mios-simulator-version-min=8.3 -Xlinker -dependency_info -Xlinker /Users/Allister/Library/Developer/Xcode/DerivedData/Haze_Meter-dkjjcmjehyitmcbhkcbujnsrhwpu/Build/Intermediates/Haze\ Meter.build/Debug-iphonesimulator/Haze\ Meter.build/Objects-normal/x86_64/Haze\ Meter_dependency_info.dat -o /Users/Allister/Library/Developer/Xcode/DerivedData/Haze_Meter-dkjjcmjehyitmcbhkcbujnsrhwpu/Build/Products/Debug-iphonesimulator/Haze\ Meter.app/Haze\ Meter
Run Code Online (Sandbox Code Playgroud)
在底部:
ld: file too small (length=0) file '/Users/Allister/Library/Developer/Xcode/DerivedData/Haze_Meter-dkjjcmjehyitmcbhkcbujnsrhwpu/Build/Intermediates/Haze Meter.build/Debug-iphonesimulator/Haze Meter.build/Objects-normal/x86_64/ViewController.o' for architecture x86_64
clang: error: linker command failed with exit code 1 (use …Run Code Online (Sandbox Code Playgroud) 我想创建一个可以在整个应用程序中访问的全局自定义对象数组(AppDelegate,ViewController类,TableViewController类等).我已经研究过一种方法,但还没有找到答案.我已经尝试过为数组提供一个公共范围,但我得到一个编译器警告说Declaring public variable from internal class,当我尝试在另一个文件中访问它时,我收到一个错误Use of unresolved identifier 'arrayObjectives'
我将如何使该数组全局可访问应用程序中的所有文件以及在哪里实例化该数组?
我正在尝试将网络连接检测集成到我的应用程序中,但是,由于我的网络更改未被检测到/打印到控制台中,因此我似乎在某处出错.
正如帖子中提到的,我目前正在使用以下类和工具来完成这项工作:
{.h, .m} NSNotificationCenter码
在AppDelegate.Swift中,我设置了NSNotificationCenter检测更改:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// ...
// A: Checks if the device is connected to the internet
var defaultCenter: Void = NSNotificationCenter().addObserver(self, selector:"checkForReachability", name: kReachabilityChangedNotification, object: nil)
Run Code Online (Sandbox Code Playgroud)
}
在同一个类中AppDelegate,我还创建了此函数,以便在发生更改时触发:
func checkForReachability () {
var networkReachability = Reachability.reachabilityForInternetConnection()
networkReachability.startNotifier()
var remoteHostStatus = networkReachability.currentReachabilityStatus()
if (remoteHostStatus.value == NotReachable.value) {
println("Not Reachable")
} else if (remoteHostStatus.value == ReachableViaWiFi.value) {
println("Reachable …Run Code Online (Sandbox Code Playgroud) 所以我正在创建一个像:
为此,我试图使用一个故事板,我添加2个TableViews(都作为'静态单元'),然后我直接从故事板手动添加我的Cell内容...
在我的故事板中,它看起来很棒但是当我构建时,我得到:
en.lproj/MainStoryboard.storyboard:错误:非法配置:静态表视图仅在嵌入UITableViewController实例时有效
如果你们对这个问题有任何想法.
谢谢 !
UINavigationItem我的视图控制器上有一个,我正在尝试减少两者之间的间距RightBarButtonItems.这是我的一些代码:
// Create two UIBarButtonItems
let item1:UIBarButtonItem = UIBarButtonItem(customView: view1)
let item2:UIBarButtonItem = UIBarButtonItem(customView: view2)
var fixedSpace:UIBarButtonItem = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.FixedSpace, target: nil, action: nil)
fixedSpace.width = -20.0
// Add the rightBarButtonItems on the navigation bar
viewController.navigationItem.rightBarButtonItems = [item2, fixedSpace, item1]
Run Code Online (Sandbox Code Playgroud)
可以看出,我使用的是FixedSpace UIBarButtonItem,但由于某些原因,这并没有改变间距.我曾经想过继承无论是UINavigationItem或UIBarButtonItem,这样我可以设置相应的间距,但我似乎无法找到,我可以重写改变项目之间的间距的任何方法.
任何有关如何解决这个问题的见解将不胜感激!
我有一个tabBar+ NavigationViewController.选项卡栏具有带单元格的集合视图(Say view1),单元格中的push seague实现到另一个视图(Say view2).
在view2中我想要一个navBar但没有标签栏.
我试过了
self.tabBarController?.tabBar.hidden = true,
它适用于view2但是当我通过后退按钮返回view1时,选项卡仍然被隐藏(即使在我在viewDidLoad func中添加的view1类中).self.tabBarController?.tabBar.hidden = false
如何让标签栏重新出现在view1中?
我在迅速工作.
uitabbarcontroller uinavigationcontroller pushviewcontroller swift
swift ×9
ios ×7
xcode ×3
arrays ×1
cell ×1
ibdesignable ×1
ios8 ×1
objective-c ×1
reachability ×1
snapshot ×1
spacing ×1
static ×1
storyboard ×1
uitableview ×1
xcode6 ×1
xcode7 ×1