Tag: appdelegate

Swift:展示主要和替代(login/入职)stream程的最佳方式是什么?

我有一个应用程序,要求该人第一次启动应用程序login或创build一个帐户 。 (虽然这通常不被推荐,但这是一个相当具体的用例。) 此外,如果他们已经login, 当应用程序更新时,我想向他们展示一个屏幕,告诉他们新的function(如在iOS11中的注释,照片和音乐)。 这个逻辑应该被封装在ViewControllers还是AppDelegate中? 是否有一种机制可以用于一个或多个不依赖于多个实现的场景?

我如何连接UITableView到我的Appdelegate.m?

– (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { MainViewController *rootViewController = [[MainViewController alloc] init]; _naviControl = [[UINavigationController alloc]initWithRootViewController:rootViewController]; self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; [self.window addSubview:_naviControl.view]; self.window.backgroundColor = [UIColor whiteColor]; [self.window makeKeyAndVisible]; return YES; } 在我的AppDelegate ..! 连接到MainViewController.m

本地通知

我在我的游戏应用程序中实施了一个本地通知,每天发一次每日奖金。 当我点击通知横幅时,这一切正常,但是,当我从应用程序图标进入应用程序,本地通知不应该像它应该。 这是我的代码: -(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions{ ……. ……. application.applicationIconBadgeNumber = 0; UILocalNotification *localNotif = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey]; if (localNotif) { NSLog(@"recieved notification %@",localNotif); UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Daily Bonus" message:@"You recieved 100 free coins" delegate:nil cancelButtonTitle:nil otherButtonTitles:@"ok", nil]; [alert show]; [alert release]; NSUserDefaults *standardUserDefaults = [NSUserDefaults standardUserDefaults]; float balance = [standardUserDefaults floatForKey:kCurrentScore]; balance +=100.0f; NSLog(@"%g",balance); [standardUserDefaults […]

如何从AppDelegate中移动这些stream程,并从每个Call中设置个别代理?

我知道这不是最好的做法,所以我想知道什么是最好的方式来删除所有这些要求个别代表,以减less加载时间。 其结果是每个进给负载一旦被调用或使其asynchronous加载 – (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions { // Override point for customization after application launch. // make RSS call JSTRRSSReader *reader = [[JSTRRSSReader alloc] init]; [reader startRequest]; BUSINESSReader *busreader = [[BUSINESSReader alloc] init]; [busreader startRequest]; SPORTSReader *sportreader = [[SPORTSReader alloc] init]; [sportreader startRequest]; LIFESTYLEReader *lifestylereader = [[LIFESTYLEReader alloc] init]; [lifestylereader startRequest]; TEENAGEReader *teenagereader […]

无法声明另一个窗口

我试图在MyThing.m中声明另一个窗口 @property (nonatomic, strong) UIWindow *window; 但是得到这个错误 非法重新宣布类扩展“MyThing”中的财产(属性必须是“读取”,而其主要必须是“只读”) 如果我把窗口重命名为其他东西,那就OK了。 这是为什么? 窗口意味着在AppDelegate.h中声明一次?

表格添加SWRevealViewController后不加载数据

经过一些拙劣的工作,我已经添加了一个揭示视图控制器到我的应用程序,但现在似乎并没有加载数据。 我无法看到我的更改会影响应用程序的哪个方面。 在didFinishLaunchingWithOptions我改变了 STRTableViewController *tableViewController = [(UINavigationController *)self.window.rootViewController viewControllers][0]; self.delegate = tableViewController; 因为rootViewController不再是表视图: // in .m interface @property (nonatomic, strong) STRTableViewController *tableViewController; … // in didFinishLaunchingWithOptions self.tableViewController = [[STRTableViewController alloc] init]; self.delegate = self.tableViewController; 然后(也在AppDelegate)我调用tableViewController方法来获取和加载表数据 – (void)loadTableViewData { [self.tableViewController loadTableData] } 另外,有点更多的信息。 首次启动时,应用程序加载一些虚拟数据,并通过一个简短的教程。 在本教程结束时,应用程序请求位置服务,然后根据用户是否接受或使用反向地理位置来加载表中的实际数据。 本教程的虚拟数据加载,但实际数据不。 在添加揭示VC之前,两者都在表格视图中加载完美,所以我不确定为什么这会随着我在这里做的小改变而改变。 任何build议将不胜感激。 谢谢!

在容器视图之间从TextField中委托文本

我试图通过文本forms一个TextField到另一个TextField。 它们都位于不同的ContainerView中。 用户可以通过分段控制在不同的ContainerView之间切换(因此,我的所有ContainerView都位于具有分段控制的ViewController中)。 我试图用委托来做到这一点:每当TextFieldOne中的文本发生变化,这种变化应该会影响另一个textField,所以,我尝试在第一个容器中的TextField上使用“Value Changed”事件的操作: protocol AddOneWordViewControllerDelegate: class { func changeTexeValue(_ text: String) } class AddOneWordViewController: UIViewController, UITextFieldDelegate { @IBOutlet weak var oneWordAddWord: UITextField! weak var delegate: AddOneWordViewControllerDelegate? override func viewDidLoad() { super.viewDidLoad() self.oneWordAddWord.delegate = self } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() } override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { self.view.endEditing(true) } func […]

线程1:加载AVPlayer时EXC_BAD_ACCESS(code = EXC_I386_GPFLT)

我想加载一个AVPlayer,当我select一个collectionViewCell,这是我didSelectItem代码: func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { if let item = items?[indexPath.item] { showPlayer(item: item) } } func showPlayer(item: Item) { let playerLauncher = PlayerLauncher() playerLauncher.showVideoPlayer() let playerView = PlayerView() playerView.item = item playerView.setupPlayerView() } 这是我的PlayerLauncher文件: class PlayerView: UIView { var item: Item? { didSet { if let id = item?.itemId { itemId […]

如何在没有用户交互的情况下在后台接收iOS通知

我使用以下方法在AppDelegate接收通知。 当用户在前台通知收到如预期的。 但是,如果用户在后台通知,只有当用户点击一个popup窗口时才会收到(在AppDelegate中)通知。 当应用程序在后台运行时如何接收通知,而不涉及用户点击。 – (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler { NSLog( @"Handle push from foreground" ); // custom code to handle push while app is in the foreground [[ACBRemoteNotificationManger sharedManager] addNotificationFromUNNotification:notification]; } – (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler { NSLog( @"Handle push from background or closed" ); // if you set […]

从UIViewController更改AppDelegate的属性不起作用

我遇到了一个在AppDelegate内部的问题,我创build了一个属性来在应用内共享值。 @property (nonatomic, retain) User *currentUser; User对象的定义是 @property int points; @property (nonatomic, copy) NSString *userName; 我有一个显示当前用户名的字段的UIViewController A. 点击一个button将调出UIViewController B和里面的UIVIewController B,我尝试更改值: // I print out these two values here 1 ((AppDelegate*)[UIApplication sharedApplication].delegate).currentUser.userName= @"newName" ; ((AppDelegate*)[UIApplication sharedApplication].delegate).currentUser.points= 19 ; // I print out these two values here 2 从1和2打印输出, userName已成功更改。 但是,当我从B传递控件回到A时,UIViewController A中的userName字段尚未更新。 在我的ViewController A中,我有: – (void)viewWillAppear:(BOOL)animated{ textField.text […]