viewcontroller

Passing data between 2 view controllers in Swift

巧了我就是萌 提交于 2019-12-11 03:29:37
问题 I have 2 view controllers, created separately. It's not navigation controller or other. I've 2 files for each of them: ViewController.swift , SecondViewController.swift . Second VC is called audioList In 1-st VC I have a button and by clicking on it I'm opening second VC using code dispatch_sync(dispatch_get_main_queue(), { () -> Void in let storyboard = UIStoryboard(name: "Main", bundle: nil) let controller = storyboard.instantiateViewControllerWithIdentifier("SecondViewController") as!

Error in Xcode “the view outlet was not set.'”

人走茶凉 提交于 2019-12-11 03:21:57
问题 I've a problem in Xcode. Every time I run my app in Simulator, the app is stopped in a black screen view and the debugger write this code: 2012-07-04 11:54:08.348 myApp[661:f803] * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "myappViewController" nib but the view outlet was not set.' Searching through the web I've read to set the link between view and View in Outlets. For "File's Owner" ->

Open view controller when remote notification pressed

一世执手 提交于 2019-12-11 03:07:16
问题 My app allows users to send a message to their friends. They then get a push notification. How can I get the view controller with the incoming messages to be opened when the app is opened via the notification? 回答1: To do that you will need to override app delegate didFinishLaunchingWithOptions function and check if launchOptions contains any notification key: func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { if let

-[UIView setShowsFPS:]: unrecognized selector error

坚强是说给别人听的谎言 提交于 2019-12-11 03:04:24
问题 I need to open a ViewController when a UIButton was press , for doing that I use the following code : NSString * storyboardName = @"Main"; UIStoryboard *storyboard = [UIStoryboard storyboardWithName:storyboardName bundle: nil]; UIViewController * vc = [storyboard instantiateViewControllerWithIdentifier:@"ViewController"]; [self presentViewController:vc animated:YES completion:nil]; when it take the final line [self presentViewController:vc animated:YES completion:nil]; it give me the

Pass custom class data between view controllers in Swift

会有一股神秘感。 提交于 2019-12-11 02:54:01
问题 I have two view controllers one that contains a tableview and another that contains the page to show following selection of a particular row. At the start of my viewController i have my Class variable instantiated var myTableViewItem = Item() I have got the selected row information from the data array: ... func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { myTableViewItem = pList[indexPath.row] println("\(itemViewItem.getItemName())")

Same button across all view controllers in ios app

风流意气都作罢 提交于 2019-12-11 01:46:52
问题 I am developing an app with 10 view controllers, including 2 webview controllers. Every view controller contains a 'send feedback' button on top right with exactly same style and functionality. Right now, I am writing exact same code in each view controller for the buttons. I was wondering if there is a way to write the method only at one place and use it for all the buttons, since the function is same. I am using swift 3. 回答1: Create new subclass of view controller: class

swift accessing variable from another file

人走茶凉 提交于 2019-12-10 22:47:09
问题 I am a newbie swift programmer, and I have been asked to write an app that allows you to type in a word, and then generates a random Haiku This is a tabbed application, with two ViewControllers. (poem) based on that word. So in the FirstViewController I have the data, and I want to display that data in a nice way, in the SecondViewController. I have all the poem lines and all in the FirstViewController, but I would like to access these variables in the SecondViewController. I have tried

MFMessageComposeViewController not working

谁都会走 提交于 2019-12-10 15:45:05
问题 I have a simple method that gets one argument and then sends a message. It is not working. Code: - (void)sendSMS:(NSString *)text { MFMessageComposeViewController *viewController = [[MFMessageComposeViewController alloc] init]; viewController.body = text; viewControllerM.mailComposeDelegate = self; [self presentViewController:viewController animated:YES completion:nil]; } What's wrong? 回答1: You need to set the delegate: MFMessageComposeViewController *controller = [[

2 XIB and 1 viewcontroller but functions don't work in the ipad XIB

不打扰是莪最后的温柔 提交于 2019-12-10 11:48:23
问题 I believe that I did everything necessary to change my app for ipad (was for iphone at start). I can toggle the build status to either iphone (only), ipad (only) or iphone/ipad - and the app launches either in ipad or iphone simulator. I can do that forth and back at will. I added the idiom to check for ipad and basically for one of my xib, instead of using the string of my xib to create the controller, I use the one for the ipad. So it is a new xib for ipad with all same graphical objects (

multiple ViewControllers (containerView? childView? instance of viewController?)

£可爱£侵袭症+ 提交于 2019-12-10 10:18:29
问题 I need to have a new view(w/ ViewController) added over the top of another. The user interacts with this new view for a while, and then I want to remove it. In an older version of Xcode I was able to add it as a subview. I now get an EXC_BAD_ACCESS error. I don't want the added view as a modal. I need to see the original background through the added view. I've read a lot about the new custom containerViews, addChildView, & presentView. I can't see that any of these are the clear answer. Here