我正在尝试按下按钮来弹出一个弹出窗口.试图按照我在谷歌中找到的说明,但我的流行视图以全屏显示,其背景为黑色.这是我的代码:
class ViewController: UIViewController, UIPopoverPresentationControllerDelegate {
@IBAction func someButtonPressed(sender: UIButton) {
let storyboard : UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let popupVC = storyboard.instantiateViewControllerWithIdentifier("hello") as! popupViewController
popupVC.modalPresentationStyle = .Popover
popupVC.preferredContentSize = CGSizeMake(300, 300)
let pVC = popupVC.popoverPresentationController
pVC?.permittedArrowDirections = .Any
pVC?.delegate = self
pVC?.sourceView = sender
pVC?.sourceRect = CGRect(x: 100, y: 100, width: 1, height: 1)
presentViewController(popupVC, animated: true, completion: nil)
}
}
Run Code Online (Sandbox Code Playgroud)
我做错了什么?
有什么方法可以检查某些字符串是拉丁字母还是西里尔字母吗?我尝试过localizedCompareString 方法,但它没有给我所需的结果。
刚刚开始编写objective-c编程,现在我遇到了自己无法解决的问题.我正在从异步请求接收数据并尝试将其转发为单例,但它没有改变.
这是我正在尝试存储我的数据
Data.h的地方
#import <Foundation/Foundation.h>
@interface Data : NSObject
@property (nonatomic, strong) NSDictionary *products;
-(void)setProducts:(NSDictionary *)value;
@end
Run Code Online (Sandbox Code Playgroud)
Data.m
#import "Data.h"
@implementation Data
+(Data *)sharedInstance
{
static Data *_sharedInstance = nil;
static dispatch_once_t oncePredicate;
dispatch_once(&oncePredicate, ^{
_sharedInstance = [[Data alloc] init];
});
return _sharedInstance;
}
- (id)init {
self = [super init];
if ( self )
{
_products = [[NSDictionary alloc] init];
}
return self;
}
@end
Run Code Online (Sandbox Code Playgroud)
这是我从服务器接收数据的类:
ConnectionService.m
- (void)getProductsWithCompletion:(void (^)(NSDictionary *products))completion
{
NSString *urlString = [NSString stringWithFormat:@"serverurl", [[AppDelegate instance]getUrl]]; …Run Code Online (Sandbox Code Playgroud) 首先需要说的是,我不使用 CocoaPods。这是我第一次使用 Google API。
在 Google 指南中说我需要GIDSignIn在application:didFinishLaunchingWithOptions:方法中进行配置,但我也使用在此方法中配置的 Facebook API。此外,当我尝试在此方法中配置 G API 时,我收到错误:Type 'AppDelegate' does not conform to protocol 'GIDSignInDelegate'和Value of type 'GIDSignIn' has no member 'configureWithError'.
如何GIDSignIn在 AppDelegate 中不配置?
Bridging Header
#ifndef Bridging_Header_h
#define Bridging_Header_h
#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <FBSDKLoginKit/FBSDKLoginKit.h>
#import <Bolts/Bolts.h>
#import <GoogleSignIn/GoogleSignIn.h>
#endif
AppDelegate
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// var configureError: NSError?
// GGLContext.sharedInstance().configureWithError(&configureError) …Run Code Online (Sandbox Code Playgroud)