Tag: segue

如何在Swift中的两个场景之间传递数据?

我有两个场景,我想通过一个segue将一个variables传递给另一个场景。 我已经尝试,但不幸的是,我所看到的所有教程都处理故事板。 我不使用故事板。 我正在通过编程来完成这一切。 这是我想要初始化的segue: func prepareForSegue(segue: UIStoryboardSegue!, sender: AnyObject!) { if (segue.identifier == "segueTest") { var lose = segue.destinationViewController as! loserScene; lose.toPass = scoreLabelNode.text } } 失败者场景是我的第二个场景。 scoreLabelNode.text是我用作分数的NSTimer的文本。 我想将scoreLabelNode.text移到另一个场景,这是我的失败者场景。 我的失败者场景是这样设置的: import SpriteKit import Foundation let GameOverLabelCategoryName = "gameOverLabel" class loserScene: SKScene { var toPass: String! var scoreLabel = SKLabelNode(fontNamed:"[z] Arista Light") override func didMoveToView(view: […]

有条件的塞维特

我想在我的应用程序中做一个“连接”button。 而当你点击它,它会打开一个新的页面,如果你有正确的login。 但是,我读了,我们不能撤消一个segue,我想我需要手动调用它。 你有好主意吗 ? 我仍然尝试这样的事情: override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject) { if checkLog == true { //finish } else { // undo } } @IBAction func ConexTAP(sender: UIButton) { //check login }

以编程方式从UIBarButtonItem继续

我有三个视图控制器,每个都在导航栏的右侧和左侧各有两个button,如下面其中一个所示。 我以编程方式创build这些button,而不是编写代码在每个相应的视图控制器(VC),我决定写一个助手类,创buildbutton。 // Note: I am using FontAwesome as a third-party library. class Helper: NSObject { static func loadNavBarItems(vc: UIViewController) { let profileButton = UIBarButtonItem() let addButton = UIBarButtonItem() let attributes = [NSFontAttributeName: UIFont.fontAwesome(ofSize: 20)] as [String: Any] profileButton.setTitleTextAttributes(attributes, for: .normal) addButton.setTitleTextAttributes(attributes, for: .normal) profileButton.title = String.fontAwesomeIcon(name: .userCircle) addButton.title = String.fontAwesomeIcon(name: .plus) vc.navigationItem.leftBarButtonItem = profileButton […]

为什么我不能在xcode 6.1中使用show segue?

所以我正在做另一个swift项目的testing,我想连接一个embedded了NavigationController的TableViewController到一个常规的ViewController使用barbutton项和第二个ViewController 。 当我控制拖动button到ViewController ,我只能得到以下选项: 据我所知,我应该看到一个很长的清单,包括显示和显示细节。 即使我用push或其他segue连接它们,如果select了segue,我也不能selectshow或show detail作为segue的types。 我究竟做错了什么? 我没有修改ViewController.swift 。 谢谢!

两个控制器之间使用故事板传递数据

我想从一个UITableViewController传递数据到另一个。 这是我在初始视图控制器中的代码: – (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { Subject *subject = (Subject *)[self.fetchedResultsController objectAtIndexPath:indexPath]; [self showList:subject animated:YES]; [self.tableView deselectRowAtIndexPath:indexPath animated:YES]; } – (void)showList:(Subject *)subject animated:(BOOL)animated { ListsViewController *lists = [[ListsViewController alloc] initWithStyle:UITableViewStyleGrouped]; lists.subject = subject; NSLog(@"%@", lists.subject); [self performSegueWithIdentifier:@"showDetail" sender:self]; } 日志输出显示它已经传递了我想要的数据。 但是,当我执行segue并logging在ListsViewController的subject显示为空。 有任何想法吗?

如何将数据从一个视图控制器传递到另一个SWIFT

我正在制作一个应用程序,其中带有search栏和范围栏的表格视图必须延伸到详细信息视图控制器,并且该详细信息视图控制器必须根据所选单元格显示数据。 我有一个数组结构来设置sorting和search的项目。 我需要保持这个function,我有我的详细信息视图控制器的另一个Swift类,我将放入if / else语句到显示基于我select的单元格的数据处理。 我需要知道如何做的是将一个variables附加到单元格,并将该variables传递给详细视图控制器以在我的if / else语句中使用,以便我可以显示数据。 如果这不是正确的方法,请让我知道。 结构代码 struct Booth { let category : String let name : String } 表视图控制器代码 import UIKit class BoothsTableViewController: UITableViewController { var booths = [Booth]() var filteredBooths = [Booth]() override func viewDidLoad() { super.viewDidLoad() //fill array with data self.booths = [Booth(category: "Tech", name: "Conference App"), Booth(category: "Tech", […]

正确访问Segue的目标视图控制器来分配协议代理

在实现select列表时,我遇到了在集成segue和协议时遇到的一些问题。 在我的select列表中.h我有: #import <UIKit/UIKit.h> @protocol SelectionListViewControllerDelegate <NSObject> @required – (void)rowChosen:(NSInteger)row; @end @interface SelectColor : UITableViewController <NSFetchedResultsControllerDelegate> -(IBAction)saveSelectedColor; @property (nonatomic, strong) id <SelectionListViewControllerDelegate> delegate; @end 在我的select列表.m我有: @implementation SelectColori @synthesize delegate; //this method is called from a button on ui -(IBAction)saveSelectedColore { [self.delegate rowChosen:[lastIndexPath row]]; [self.navigationController popViewControllerAnimated:YES]; } 我想通过从另一个表视图执行segue来访问这个select列表视图: @implementation TableList … – (void)selectNewColor { SelectColor *selectController […]

赛格在简单的赛格testing中不起作用

我有一个奇怪的问题。 我在故事板中创build了2个viewcontroller: testSegueViewcontroller和nextPageViewController 。 testSegueViewcontroller包含一个UIButton NextPage。 我按住Ctrl键,从这个button拖到nextPageViewController并创build一个Push segue。 问题是当我运行这个程序,然后单击TestSegueViewcontroller中的NextButton它不显示nextPageVieController 🙁 任何想法我做错了什么?

IOS应用程序 – 在同一时间多个赛格崩溃(去其他赛格,而一个是animation)

虽然一个segue(如perforrmsegue)的animation正在进行,如果其他segue发生(如果用户在那时按其他button),然后应用程序崩溃。 这里解决了 UINavigationController上pop和pushViewController的问题。 我们还可以使用同样的trik还有其他解决scheme。 崩溃后我得到下面的堆栈。 (在[NSException initWithCoder:]处执行)。 0 CoreFoundation 0x2f9fbf4b __exceptionPreprocess 1 libobjc.A.dylib 0x39d8b6af objc_exception_throw 2 CoreFoundation 0x2f9fbe8d -[NSException initWithCoder:] 3 UIKit 0x3217a48f -[UIView(Internal) _addSubview:positioned:relativeTo:] 4 UIKit 0x3217a417 -[UIView(Hierarchy) addSubview:] 5 UIKit 0x32342b71 __53-[_UINavigationParallaxTransition animateTransition:]_block_invoke 6 UIKit 0x321806e5 +[UIView(Animation) performWithoutAnimation:] 如果这个豁免是由于任何其他原因,那么请提及,因为我不知道有关赛格。

prepareForSegue是在视图控制器之间传递值的正确方法

我正在努力学习Swift,我正在努力开发着名的笔记应用程序。 有一个数组绑定到tableview和另一个视图来添加注释。 在第二个视图textfieldshould返回事件触发segue并返回到tableview。 我想知道这是否正确。 因为通过这样做我操纵另一个视图控制器中的variables。 我不是一个MVC主,但我觉得这是错的。 这是我的代码片段: func textFieldShouldReturn(textField: UITextField) -> Bool { self.performSegueWithIdentifier("backSegue", sender: self) return true } override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { if(segue.identifier == "backSegue"){ let navController = segue.destinationViewController as UINavigationController; let myController = navController.topViewController as NotesTableViewController; if(self.ourTextField?.text != nil || self.ourTextField?.text != ""){ myController.notes.append(self.ourTextField?.text ?? ""); } } } 谢谢。