viewcontroller

How to make cells have a gradient background?

前提是你 提交于 2019-11-29 12:50:10
I have inserted a table view on my view controller and I was wondering how can I give the cells in the table view a gradient background? Can I edit each cell individually to give it a different color gradient background for each cell? For example, each cell is labeled after an index in the trainingLevels array, how could I make to where each has a different color gradient background? Here's my code: import UIKit class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { var trainingLevels = ["Ball Handling", "Shooting", "Defense", "Advanced Drills", "Vertimax Drills",

iOS: Is there currently a way to prevent two view controllers being pushed or popped at the same time?

微笑、不失礼 提交于 2019-11-29 12:31:06
The only solution I have seen was an answer to a stackoverflow question. I posted the link below. The answer I am referring is the 5th one. It seems that some users have some problems with the solution however. I don't know if there is another category to prevent two controllers from being pushed at the same time. Any tips or suggestions are appreciated. #import "UINavigationController+Consistent.h" #import <objc/runtime.h> /// This char is used to add storage for the isPushingViewController property. static char const * const ObjectTagKey = "ObjectTag"; @interface UINavigationController ()

Modal view closes when selecting an image in WkWebView iOS

泪湿孤枕 提交于 2019-11-29 07:03:34
I'm currently building an app with a modal view popping up that contains a WkWebView. When I want to upload an image within this modal view and the Photo Selection appears, the modal view just dismisses back to the view controller that fired it up. How can I prevent that? import UIKit class PostWindow : UIViewController { @IBAction func close(sender: AnyObject) { dismissViewControllerAnimated(true, completion: nil) } override func viewDidLoad() { super.viewDidLoad() // do stuff here let myWebView:UIWebView = UIWebView(frame: CGRectMake(0, 70, UIScreen.mainScreen().bounds.width, UIScreen

Hide/Show iAds in Spritekit

丶灬走出姿态 提交于 2019-11-29 04:25:12
I've been trying to figure out how to hide and show iAds in my Spritekit Scenes. Currently I have it setup like this: ViewController.h #import <UIKit/UIKit.h> #import <SpriteKit/SpriteKit.h> #import <iAd/iAD.h> @interface ViewController : UIViewController <ADBannerViewDelegate> { ADBannerView *adView; } -(void)showsBanner; -(void)hidesBanner; @end ViewController.m #import "ViewController.h" #import <UIKit/UIKit.h> #import <iAd/iAD.h> #import "MyScene.h" #import <SpriteKit/SpriteKit.h> @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; // Configure the view. SKView *

What is better place for loading data from API- viewDidLoad, viewWillAppear or viewDidAppear?

99封情书 提交于 2019-11-29 04:22:21
I am making an IOS app where i am calling an API in viewDidLoad method of view controller. Now i want to reload the same view controller with the data that comes from server. How many ways are there to do this task and what would be the best way?? Please help me. Thanks!! JAY RAPARKA viewDidLoad method is called first time when UIViewController is first loaded and when it pop and then you reenter in it at that time viewDidLoad is called. So if you want to load the API only once then viewDidLoad is the best place to call an API. viewWillAppear called every time when you enter in that

How to dismiss the current ViewController and go to another View in Swift

£可爱£侵袭症+ 提交于 2019-11-29 01:38:18
I am new to Swift and I want to know how to dismiss the current view controller and go to another view. My storyboard is like the following: MainMenuView -> GameViewController -> GameOverView. I want to dismiss the GameViewController to go to the GameOverView, not to the MainMenuView. I use the following code in my MainMenuView: @IBAction func StartButton(sender: UIButton) { let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil) let nextViewController = storyBoard.instantiateViewControllerWithIdentifier("GameViewController") as! GameViewController self.presentViewController

Loading ViewController from xib file

江枫思渺然 提交于 2019-11-29 00:31:08
问题 I had a MyViewController.swift and a MyViewController.xib presenting the layout of MyViewController. I tried different methods to load this view controller including: //1 let myVC = UINib(nibName: "MyViewController", bundle: nil).instantiateWithOwner(nil, options: nil)[0] as? MyViewController //2 let myVC = NSBundle.mainBundle().loadNibNamed("MyViewController", owner: self, options: nil)[0] as? MyViewController //3 let myVC = MyViewController(nibName: "MyViewController", bundle: nil) The

How can I remove a view from navigation controller

狂风中的少年 提交于 2019-11-28 21:35:43
I want to call a new view controller and remove the current view controller from the navigation controller stack. For example. I am in view controller A and I call B. Now I have in the stack A , B. Now I want to call C (from B). I want the stack to be A, C. Thanks. JohnK In the context of ARC, here's a possible solution: NSMutableArray* navArray = [[NSMutableArray alloc] initWithArray:self.navigationController.viewControllers]; [navArray replaceObjectAtIndex:[navArray count]-1 withObject:nextViewController]; [self.navigationController setViewControllers:navArray animated:YES]; As you can tell,

App running slow after loading viewcontroller, then unload about 15-20 times

我是研究僧i 提交于 2019-11-28 14:43:20
Using: Xcode 4.6 Storyboards ARC Model segue to SecondViewController I have an app that has the main ViewController that loads a new veiwController when the device is rotated to the right. When the app starts everything works great. If I rotate the device, then back which unloads the secondview controller, about 15-20 times the app is very slugish. I have narrowed down that it only happenes when the seconed view controller is loaded and only when i rotate the device a nunmber of times. I also have narrowed down that is is a memory issue. I installed an app that keeps track of the memory used

Apple Watch notification issue: WatchKit error - unable to find interface controller class to instantiate

断了今生、忘了曾经 提交于 2019-11-28 14:42:00
I am getting the following error when I am trying to push my notification controller dynamically. 2015-03-30 13:18:53.324 MyApp WatchKit Extension[79826:1951724] Took too long to show custom notification. Falling back to static. 2015-03-30 13:26:13.831 MyApp WatchKit Extension[79826:1957863] WatchKit error - unable to find interface controller class '_TtC26MyApp_WatchKit_Extension19InterfaceController' to instantiate I heard there might be a glitch, but as far as I am concern it is only occurring on the Xcode beta and not Xcode 6.2. I change the module regarding the notification storyboard to