Tag: 查看

如何从xib调用performSegueWithIdentifier?

我有viewController与segue secondViewController名为“toSecond”。 在viewController我加载customView.xib let myCustomView = NSBundle.mainBundle().loadNibNamed("customView", owner: self, options: nil)[0] 在这个customView我有button的行动: viewController().goToSecond() 在viewController我有这个代码的function func goToSecond() { self.performSegueWithIdentifier("toSecond", sender: self) } 但是当我按下customView中的button,我成为一个错误: viewController没有标识符“toSecond” 当我直接从viewController调用这个函数都很好! 那么,我怎样才能从我的customView调用performSegueWithIdentifier? customView源代码: import UIKit class customView: UIView { @IBAction func ToSecondButton(sender: AnyObject) { viewController().goToSecond() } } viewController源代码: import UIKit class viewController: UIViewController { … let myCustomView = NSBundle.mainBundle().loadNibNamed("customView", owner: self, options: […]

如何在iOS中获取当前单元格外的触摸?(swift)

我正在创build一个自定义的SwipeableCell左/右。 我想检测当前单元格外的触摸,使其返回到默认状态。 我怎样才能做到这一点? 我的程序的图片 我知道如何将单元格返回到默认状态,但我不知道如何检测触摸。

iOS Swift – CGSizeFromString抛出CGSizeZero

我有这个function是用来从string长度设置大小。 类似的东西 – Swift iOS – 标签集合视图 。 项目中的第一项是“年龄” func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize { var cellWidth : CGSize = CGSizeFromString(self.categoriesItems[indexPath.row].name); return cellWidth }

如何改变视图的尺度

我正在尝试使应用欧元运动的边栏菜单! 当菜单从左侧滑动时, sourceviewcontroller向左滑动并变小。 var percentWidthOfContainer = containerView.frame.width * 0.2 // this is 20 percent of width var widthOfMenu = containerView.frame.width – percentWidthOfContainer bottomView.transform = self.offStage(widthOfMenu) bottomView.frame.origin.y = 60 bottomView.frame.size = CGSizeMake(widthOfMenu, 400) bottomView.updateConstraints() menucontroller.view.frame.size = CGSizeMake(widthOfMenu, containerView.frame.height) menucontroller.updateViewConstraints() 在这里,底部视图是sourceviewcontroller.view。 所以,问题是如何缩放底部视图。 在我的情况下,我可以改变大小,但视图内的一切仍然是相同的大小。

访问内容scaleFactor / multiplier?

我正在使用iPhone 6 Plus,并使用我的UIView的边界: let viewBounds = view.bounds // GIVES 736 x 414 (Points), WHICH IS RIGHT 有什么办法,我可以得到乘数(即@ 3X),用于将点转换为像素。 我希望我可以使用: let scaleFactor = view.contentScaleFactor // GIVES 1 但是你可以看到它总是返回1.我知道我可以直接使用preferredMode.size或nativeBounds获取屏幕大小,但是我确定以前也有访问乘法器的方法吗? // WHERE SCALE FACTOR WOULD BE 3 let yRes = viewBounds.height * scaleFactor // 736 x 3 = 2208 let xRes = viewBounds.width * scaleFactor // 414 x […]

限制某些视图的自动旋转

我的应用包含两个表格视图控制器。 在第一个我希望能够左右旋转视图(除了肖像模式),但是在第二个表视图控制器(我从第一个表中点击单元格后导航)我想要它只能在肖像模式下查看。 我试过这个代码,但它没有工作,它一直在旋转。 – (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskPortrait; } – (BOOL) shouldAutorotate { return NO; } 注意:我确实从项目目标的摘要选项卡启用了左/右/纵向方向。 任何修复?

iOS:有关GLKMatrix4MakeLookAt结果内相机信息的问题

iOS 5文档显示, GLKMatrix4MakeLookAt与GLKMatrix4MakeLookAt操作相同。 定义在这里提供: static __inline__ GLKMatrix4 GLKMatrix4MakeLookAt(float eyeX, float eyeY, float eyeZ, float centerX, float centerY, float centerZ, float upX, float upY, float upZ) { GLKVector3 ev = { eyeX, eyeY, eyeZ }; GLKVector3 cv = { centerX, centerY, centerZ }; GLKVector3 uv = { upX, upY, upZ }; GLKVector3 n = GLKVector3Normalize(GLKVector3Add(ev, GLKVector3Negate(cv))); […]

iOS:在屏幕上镜像内容

我想知道是否有可能在同一个设备中翻转一个UIView的内容; 不是指外部显示器,而是指设备本身。 我已经search了一下谷歌,但我能find的是外部屏幕。

如何从appDelegate展示UIAlertView

我试图显示从应用程序收到推送通知时didReceiveRemoteNotification appDelegate UIAlertView。 我有这个错误: Warning: Attempt to present <UIAlertController: 0x14c5494c0> on <UINavigationController: 0x14c60ce00> whose view is not in the window hierarchy! 这里是我的代码: func application(application: UIApplication, didReceiveRemoteNotification userInfo: NSDictionary) { var contentPush: NSDictionary = userInfo.objectForKey("aps") as NSDictionary var message = contentPush.objectForKey("alert") as String let alertController = UIAlertController(title: "Default Style", message: message, preferredStyle: .Alert) let cancelAction = […]

尽pipe在标题视图中不是在表格视图的顶部分段控制

我怎样才能把一个分段控制在一个tableview之上。 我不希望它在导航控制器的标题视图,我不希望它滚动tableview。 有关我的意思的参考,请查看App Store应用程序,select类别,然后select任何类别。 在那里你会看到我正在寻找的分段控制。 “付费”,“免费”和“发布date”分段。 我使用的代码不是IB,所以如果你知道如何回答这个代码不是IB拖放。