获取iOS键盘的高度而不显示键盘

我想获得iOS键盘的高度。 我已经经历了,并使用了订阅通知的方法,如在这里详细说明: https : //gist.github.com/philipmcdermott/5183731 – (void)viewDidAppear:(BOOL) animated { [super viewDidAppear:animated]; // Register notification when the keyboard will be show [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil]; // Register notification when the keyboard will be hide [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil]; } – (void)keyboardWillShow:(NSNotification *)notification { CGRect keyboardBounds; [[notification.userInfo valueForKey:UIKeyboardFrameBeginUserInfoKey] getValue:&keyboardBounds]; // Do something with […]

如何提取JSONstring数组?

使用http获取请求我没有得到这个jsonstring: hello [ { "upid":"1", "uptitle":"test", "uptype":"test", "upsize":"1234", "upname":"test", "upuid":"1", "uplocation":"1", "uptimestamp":"2013-04-11 09:25:40" }, { "upid":"17", "uptitle":"test", "uptype":"video\/mov", "upsize":"2232", "upname":"testing", "upuid":"1", "uplocation":"", "uptimestamp":"2013-04-12 11:47:20" } ] 我怎样才能得到它的格式输出: upid:1 uptitle:test uptype:test upsize:1234 upname:test upuid:1 uplocation:1 uptimestamp:2013-04-11 09:25:40 upid:17 uptitle:test uptype:video\/mov upsize:2232 upname:testing upuid:1 uplocation: uptimestamp:2013-04-12 11:47:20 这是我的代码: NSMutableURLRequest *GETrequest = [[NSMutableURLRequest alloc] init]; [GETrequest setURL:[NSURL URLWithString:@"http:someip/upload/?id=1&command=alluseruploads&uid=1"]]; […]

我想把表格视图精确到导航栏

请参见虚线框区域,这是导航栏和表格视图之间出现的额外空间。 我已经尝试了3件事情,但同样的问题。 1.清除所有约束和“添加缺less约束” 2.我使用了pin,并且在表格视图之上保持'0'距离UI对象 3.我已经使用了拖动方法,为表格视图设置垂直间距。

为什么我的NSURLConnection报告不正确的expectedContentLength

我有一个NSURLConnection和didReceiveResponse我正在检查[response expectedContentLength]并得到非常大的值,如18446744073709551615.这是没有办法这是正确的。 下载大约3k字节,当我期待在fiddler中有相同的请求时,我看到一个(正确的)内容长度为3k字节的响应头。

validation用户使用AWS IOS SDK进行身份validation

我创build了一个lamdba函数,它执行以下操作: var param = { IdentityPoolId: "us-east-1:the-full-identity-id", Logins: {} // To have provider name in a variable }; param.Logins["com.test.website.login"] = userIdICreatedAndStoredInDynamoDB; cognitoidentity.getOpenIdTokenForDeveloperIdentity(param, function(err, data) { if (err) return fn(err); // an error occurred else fn(null, data.IdentityId, data.Token); // successful response }); 它返回该用户的身份标识和标记。 所有内容都通过IAMangular色和AWS Cognito Identity进行设置,并在控制台中显示为正在进行身份validation。 我有两个问题: 如何在应用程序中testing用户的身份validation? 我将身份标识和令牌保存在应用程序设备中。 authentication持续多久? 我希望用户保持login。这是我使用的大多数应用程序的工作方式,并保持login状态直到他们登出。 谢谢。

Sprite Kit和位图字体

我目前正在使用Cocos2D,但也阅读新的iOS Sprite Kit文档。 但是,我无法find如何使用位图字体。 有没有什么窍门使用我的.fnt文件?

苹果推送通知不适用于分发,而是用于开发

我在我的应用程序中实施推送通知,在开发部分工作正常,我收到推送通知。 当我决定在应用程序商店发布它时,我实现了它的分发(我使用证书和configuration文件进行分发),我做了相同的步骤,并通过应用程序将.p12文件转换为.pem, certificate.pem和key.pem到另一个文件ck.pem。 在PHP文件中,我做了以下操作: $passphrase = 'The passphrase I put it in the shall'; $ctx = stream_context_create(); stream_context_set_option($ctx, 'ssl', 'local_cert', 'ck.pem'); stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase); // Open a connection to the APNS server $fp = stream_socket_client( 'ssl://gateway.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx); 我已经改变了沙箱到SSL://gateway.push.apple.com:2195在我的PHP。 我用这个步骤创build了production.pem。 $ openssl x509 -in aps_developer_identity.cer -inform der -out PushChatCert.pem $ openssl […]

UISwitch在tableviewcell的附件视图中,传递一个参数与select器有select器函数看indexpath.row?

我在tableviewcontroller中有一个UISwitch ,当开关切换时,我希望它改变我在视图控制器内创build的数组中的布尔variables的值,该单元格与此有关。 有点像IOS上的股票报警应用,每个单元都有一个UISwitch ,切换开关将closures每个单独的报警。 所以对于UISwitch ,使用它的select器代码,这是在cellForRowAtIndexPath方法中 //switch let lightSwitch = UISwitch(frame: CGRectZero) as UISwitch lightSwitch.on = false lightSwitch.addTarget(self, action: #selector(switchTriggered), forControlEvents: .ValueChanged) //lightSwitch.addTarget(self, action: "switchTriggered", forControlEvents: .ValueChanged ) cell.accessoryView = lightSwitch 我想要这样做 func switchTriggered(a: Int) { changeValueOfArray = array[indexPath.row] } 我没有为该部分编写的代码,但我的问题是,我怎么能让switchTriggered函数看到indexPath.row值,而不是作为parameter passing给函数,因为我不能因为它的select器?

用户必须login才能使用本地共享框

我想在我的应用程序中添加谷歌加上财产的份额。 我在谷歌的Web控制台注册客户端应用程序,并获得客户端ID。 在我的viewDidLoad函数中: – (void)viewDidLoad{ CGRect rect = self.view.bounds; rect.size.height = rect.size.height – 50; _postContentUIWV = [[UIWebView alloc] initWithFrame:rect]; [_postContentUIWV loadHTMLString:selectedPostCD.content baseURL:nil]; [self.view addSubview:_postContentUIWV]; self.navigationController.navigationBar.tintColor = [UIColor whiteColor]; GPPSignIn *signIn = [GPPSignIn sharedInstance]; signIn.shouldFetchGooglePlusUser = YES; // signIn.shouldFetchGoogleUserEmail = YES; // Uncomment to get the user's email // You previously set kClientId in the "Initialize […]

使用TDD在Swift中进行性能testing

在Swift学习Test Driven Development 。我在“ProjectNameTests”组中创build了一个XCTestCase子类。 class BasicFunctionTest: XCTestCase { var values : [Int]? override func setUp() { super.setUp() // Put setup code here. This method is called before the invocation of each test method in the class. } override func tearDown() { // Put teardown code here. This method is called after the invocation of each […]